Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using wordpress social login plugin. So some of my users register via facebook.

I'm trying to hook myself to user_register and display only once upon registration and upon using facebook as source some special message.

Wordpress social login plugin creates meta_key Facebook if user registered via facebook.

So I created this little script:

//save referral information passed from cookie: referral_user
add_action('user_register', 'register_referral');

function register_referral($user_id) {
   $userdata = array();
   $userdata['ID'] = $user_id;
   wp_update_user ($userdata);


    //IF user there is appropriate user_meta field.
    $user_origin = get_user_meta($user_id,'Facebook',true);

    if ($user_origin) {
      {echo 'registered via faceboook, hurey!';}
    } //master if
}

Problem is $user_origin is never evaluated true, because when this IF statement is run meta_value Facebook is not Yet created!

I tested it by putting break; before and checking DB for this field.

So, my question is this, is there a way to move my action to be the last action upon registration of user. So that first Facebook is created by social login plugin, and than I can evaluate and run my scripts.

Thanks@!

Edit:

Plugin doesn't use user_register hook.

Greped "add_action" and got:

Sandros-MacBook-Air:plugins sandro$ grep -ir "add_action" wordpress-social-login/*
wordpress-social-login/includes/plugin.auth.php:add_action( 'init', 'wsl_process_login' );
wordpress-social-login/includes/plugin.init.php:    add_action( 'admin_init', 'wsl_register_setting' );
wordpress-social-login/includes/plugin.init.php:add_action('admin_menu', 'wsl_admin_menu' ); 
wordpress-social-login/includes/plugin.init.php:add_action('admin_menu', 'wsl_admin_menu_sidebar');
wordpress-social-login/includes/plugin.ui.php:add_action( 'login_form', 'wsl_render_login_form_login' );
wordpress-social-login/includes/plugin.ui.php:add_action( 'register_form', 'wsl_render_login_form_login' );
wordpress-social-login/includes/plugin.ui.php:add_action( 'after_signup_form', 'wsl_render_login_form_login' );
wordpress-social-login/includes/plugin.ui.php:add_action( 'wordpress_social_login', 'wsl_render_login_form_login' );
wordpress-social-login/includes/plugin.ui.php:add_action( 'comment_form_top', 'wsl_render_comment_form' );
wordpress-social-login/includes/plugin.ui.php:add_action( 'login_head', 'wsl_add_javascripts' );
wordpress-social-login/includes/plugin.ui.php:add_action( 'wp_head', 'wsl_add_javascripts' );
wordpress-social-login/includes/plugin.ui.php:add_action( 'login_head', 'wsl_add_stylesheets' );
wordpress-social-login/includes/plugin.ui.php:add_action( 'wp_head', 'wsl_add_stylesheets' );
share|improve this question

2 Answers 2

What hook is the social plugin using? If it's also user_register, just delay your handler:

add_action( 'user_register', 'register_referral', 500 );
share|improve this answer
    
tried, didn't work. did grep on plugin files, it doesn't use user_register hook. Any other ideas? –  Sandro Dzneladze Nov 8 '12 at 11:07
1  
Have a gander through the source & see if you can find the hook it is using. –  TheDeadMedic Nov 8 '12 at 11:45

I figured it out, I found wordpress social login plugin uses variable $provider.

So I used that to check if it was facebook, if ($provider == 'Facebook') {echo 'works';}

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.