Adding Facebook Login Button in PHP Code

I am trying to add a new Facebook login button to my registration page on my Drupal site.

I know the following code is wrong, but I don't know the correct 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 be used instead echo

? Is there any other way I should be doing this?

+2


a source to share


1 answer


Use the right tool for the job: Facebook Connect

Oherwise:

You must use hook_form_FORM_ID_alter()

or hook_form_alter()

to change the shape. Form name: user_register "



eg.

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

      

Or, for example, you see fit.

+2


a source







All Articles