• Resolved Matteo

    (@matteofeduzi)


    Hello,

    must execute a code through the functions.php file when the user registers the first time through one of the social networks the plugin provides.

    How can I do that?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Laszlo

    (@laszloszalvak)

    Hi @matteofeduzi

    This can be achieved by using one of the actions that we offer for developers.
    The one that you probably need is the “nsl_register_new_user” action:

    From its first parameter you can get the User ID of the registered account and from the second parameter you can get the provider instance.

    So you could hook a function to this action, and in that function you could execute the code that you would like to.

    Best regards,
    Laszlo.

    Thread Starter Matteo

    (@matteofeduzi)

    Great, this worked for me:

    add_action('nsl_register_new_user', 'new_user_by_social_login');
    function new_user_by_social_login($user_id){
    	$user = new WP_User($user_id);
    	$user->remove_role( 'subscriber' );
    	$user->add_role( 'student_free_2021_2022' );
    }

    Thank you! 🙂

    • This reply was modified 2 years, 5 months ago by Matteo.
    • This reply was modified 2 years, 5 months ago by Matteo.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Execute code via functions.php when the user registers for the first time with a’ is closed to new replies.