2

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?

htoip
  • 437
  • 5
  • 19
CMaury
  • 1,273
  • 5
  • 13
  • 25

1 Answers1

2

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.

htoip
  • 437
  • 5
  • 19
coderintherye
  • 901
  • 1
  • 11
  • 20