0

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' );
1

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

add_action( 'user_register', 'register_referral', 500 );
  • tried, didn't work. did grep on plugin files, it doesn't use user_register hook. Any other ideas? – user8842 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
1

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';}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy