When a visitor want to register to the site their are redirected to user/register but there isnt a fbconect like "register with facebook" like in user/login.

Is there possible that new user can link their facebook account without the need to go throght user/login

Comments

heyyo’s picture

+1

geekgirlweb’s picture

+1

angelmax’s picture

+1

ArnaudDrupal’s picture

+1

YK85’s picture

+1 subscribing

earthday47’s picture

Until this gets in the module, there's a way to add it manually. If you look ~ Line 200 of fbconnect.module, you'll see this form alter:

        $attr = array();
        if (variable_get('fbconnect_fast_reg', 0) && variable_get('fbconnect_reg_options', 0)) {
          $attr = array('perms' => 'email');
        }
        
        $form['fbconnect_button'] = array(
          '#type' => 'item',
          '#description' => t('Sign in using Facebook'),
          '#value' => fbconnect_render_button($attr),
          '#weight' => 1,
          '#id' => 'fbconnect_button',
        );

fbconnect_render_button() function calls the THEME function fbconnect_login_button().

So you could add it yourself using hook_form_alter(). If you wanted to add it to the user/register form, you would create your own module called mymodule, and declare a function called mymodule_form_alter() that looks like this:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_register':
      if (module_exists('fbconnect')) {
        // see fbconnect.module, line 199
        #848354 : ask user for email permission when account linking is disabled
        $attr = array();
        if (variable_get('fbconnect_fast_reg', 0) && variable_get('fbconnect_reg_options', 0)) {
          $attr = array('perms' => 'email');
        }			
        $form['fbconnect_button'] = array(
          '#type' => 'item',
          '#description' => t('Sign in using Facebook'),
          '#value' => fbconnect_render_button($attr),
          '#weight' => -50,
          '#id' => 'fbconnect_button',
        );
      }
      break;
  } // end switch
}

The module_exists('fbconnect') call ensures that the FB Connect module is enabled, preventing errors and warnings.

The '#weight' => -50 adds the button at the very top of the form. If you want it at the bottom, make weight 50 (positive).

I'm using this in my module and it works great.

If you're not form altering, and you want to display the button, just add

$form = array();

just after if (module_exists('fbconnect')) {, and then at the bottom call:

drupal_render($form);

This will convert the form array to HTML. Then you have a fully formatted Facebook Connect button ready to output!

YK85’s picture

Thanks for the great info!

Would you be able to create a patch that adds this to the module?
Then it could be reviewed by a larger audience and possibly be committed?

Your help would be really appreciated!
Thank you

earthday47’s picture

Sure, I'm just not good at patching things.

I'll try to wrap it in a module for the short-term, and then add a configuration checkbox to enable/disable this feature.

earthday47’s picture

Here's a completely untested patch.

I added two new variables, fbconnect_user_reg_display and fbconnect_user_reg_location, on the "Appearance" tab of the FBConnect module, and shows the FBConnect button on the user/register page. The second variable is if the button is on the top or the bottom of the form.

earthday47’s picture

Status: Active » Needs review

changing status

wizonesolutions’s picture

Thanks #982918-6: Add login with facebook in register form! I did the same thing myself in a custom module, but missed the $attr setting and who knew, it was actually pretty important.

theatereleven’s picture

I'm looking at this stuff, but it is a little over my head. We have a custom registration page, so I have to manually print stuff on the pages. Not sure how to get this module to appear anywhere in my custom theme once enabled and configured on the back end.

Using a custom Zen based theme on Drupal 6.x / Project Mercury.

balajimca’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
StatusFileSize
new39.99 KB

i want step by step installation of fbconnect mudule and creating login with facebook option in drupal site. Anyone can help me pls. I'm using drupal 7.7. fbconnect module displaying API settings screen only, not displaying login screen in my drupal 7.7 project. I've attached my fbconnect module.

beautifulmind’s picture

StatusFileSize
new20.32 KB

Here is the improved and ported code for 7.x as provided in comment #6

function mymodule_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['or'] = array(
        '#type' => 'item',
        '#prefix' => '<div>',
        '#markup' => '<h2>'. t('OR') .'</h2>',
        '#suffix' => '</div>',
      );
      
      $form['fbconnect_button'] = array(
        '#type' => 'item',
        '#title' => t('Facebook login'),
        '#markup' => $ss__facebook_connect,
      );
      break;
  }
}

In addtion, you have to make sure that, you uncheck the box shown in red in the image attached here.

Regards.

jcisio’s picture

Status: Needs review » Fixed

A slightly modified patch from #8 is committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

venusrising’s picture

What about Drupal 6. Can someone kindly share the modified code that may work.

jsidigital’s picture

I tried code on comment #14 by "beautifulmind".
Works great!

Any idea how to create a block using this custom module?
Facebook Connect already comes with a block, but its not editable and i want to be able to add text above the button.

So using the custom module in comment #14, anyone know how this can be made into a custom block?

Thanx.

beautifulmind’s picture

@jsidigital You can try with block creating api hooks and the put the code it it. If you need help, let me know.

Regards.

beautifulmind’s picture

I have this working on http://drupaldeveloper.in/user/login

You can take a look at the code here: http://drupaldeveloper.in/codelet/drupal-login-register-facebook-connect...

Please make sure you have all the dependent modules enabled.

Regards.