In the past 2 days we have talked about the use of Facebook Connect module.
Drupal 7 – Allow Facebook login using Facebook Connect
Drupal 7 – Override the Facebook Connect login button theme
In this post, i will show you how to render the Facebook Login button programmatically in the Drupal user registration and login page.
The following code will render the Facebook Login button programmatically.
$user_profile = fbconnect_user_profile(); $attr = array(); if (variable_get('fbconnect_fast_reg', 0) && variable_get('fbconnect_reg_options', 0)) { $attr = array('perms' => 'email'); } $ss__facebook_connect = fbconnect_render_button($attr);
The $ss__facebook_connect is the HTML markup of the Facebook Login button. You can set it to the $vars in the preprocess function and then print it in corresponding .tpl.php.
If you want to add the button in the registration and login page, create a custom module and implement the following hook_form_alter().
function <module>_form_alter(&$form, &$form_state, $form_id) { $user_profile = fbconnect_user_profile(); $op = $user_profile ? 'login' : 'register'; switch ($form_id) { case 'user_register_form': case 'user_login': $attr = array(); if (variable_get('fbconnect_fast_reg', 0) && variable_get('fbconnect_reg_options', 0)) { $attr = array('perms' => 'email'); } $ss__facebook_connect = fbconnect_render_button($attr); $form['fbconnect_button'] = array( '#type' => 'item', '#title' => t('Facebook login'), '#markup' => $ss__facebook_connect, ); break; } }
Done =)
Reference:
sorry, I don’t get it. To make a custom login page I have a custom block block–user–login.tpl.php and template.php defines the hook as
where does the $ss__facebook_connect = fbconnect_render_button($attr); go?
LikeLike
Try this
LikeLike
Can you please give some more information about this ?
I’m NOOB @ drupal 😉
Thanks
LikeLike