Tutorial :Adding Facebook Log in button to PHP code



Question:

I am trying to add the new Facebook log in button to my registration page on my Drupal site.

I know the following code is wrong, but I don't know the right syntax to implement it:

function facebook_user($op, &$edit, &$user, $category = NULL) {     switch($op) {      // User is registering.       case 'register':        // Add a Facebook login button.        echo '<fb:login-button perms='email' show-faces="true" width="200" max-rows="1"></fb:login-button>';    }  }  

What should I use instead of echo? Is there another way I should be going about this?


Solution:1

Use the right tool for the job: Facebook Connect

Oherwise:

You should be using hook_form_FORM_ID_alter() or hook_form_alter() to alter the form. The form name is "user_register"

E.g.,

hook_form_user_register_alter($form, &$form_state) {    $form['values']['facebook'] = array(      '#type' => 'button',      '#value' => 'Facebook Login'    );  }  

Or such as you see fit.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »