• Resolved aaron13223

    (@aaron13223)


    Hi There,

    I hope you are doing well. I wanted to know if there’s a hook that triggers right after a user is logged in using Social Login/Nextend Login.

    I would like to invalidate all other sessions for that user so I was wondering if there’s any hook that fires right after a user logs in using Nextend.

    If I am to explain further, what I want to achieve in particular is to use a hook that fires right after a user links their social account (If they already have an account). – Currently I have it set up such that the profile is linked automatically and user is logged in (I want to keep this behaviour)

    I would really appreciate your help on this. Thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Robert

    (@robertnextendweb)

    Hi @aaron13223

    Please note that we cannot provide support for custom coding, so that must be handled by you. As for hooks, we have the “nsl_login” action, which is fired after someone has logged in with either of the providers:
    https://social-login.nextendweb.com/documentation/for-developers/hooks/#login
    You can also use the provider id variant if you want only one provider.

    If you are looking for one that is fired after a link happens, you can use the nsl_{{provider_id}}_link_user action:
    https://social-login.nextendweb.com/documentation/for-developers/hooks/#nsl-link-user
    where the provider id is “google” for Google, “fb” for Facebook, and “twitter” for X/Twitter.

    Thread Starter aaron13223

    (@aaron13223)

    Hi @robertnextendweb ,

    Thanks a lot for your help! nsl_{{provider_id}}_link_user action is what I was looking for.

    I have one other question but it’s completely okay if you don’t answer since I understand custom code is out of scope.

    Do you think wp_get_session_token() will work well in this context of the nsl action to get the session token of the user who just linked their social account?

    Thanks again for your help!

    Plugin Support Laszlo

    (@laszloszalvak)

    Hi @aaron13223

    That hook is probably not the best option for that purpose, because this hook gets triggered whenever a social media account is linked to a WordPress account. This can happen both:

    • when the user is already logged in, e.g. when a logged in user links a social media account manually to the currently logged in WordPress account )
    • or when the user is not logged in yet, e.g. when we have to register a new WordPress account and link the social media account to the account that we created ( this happens before we log the user in to the connected WordPress account )

    The wp_get_session_token() function retrieves the token from the logged_in cookie, which requires the user to be logged in already. So you probably need to prepare your code for both cases or you should use rather the nsl_login action hook that Robert suggested earlier, as we fire that action only when we the user logs in with social login. With the 2nd approach, I don’t really think a reason you should invalidate the other session tokens for the already logged in users who link a social media account with the link button, as you might have already invalidated the other tokens at the time the user logged in with the social login ( or traditional login if you implemented it for that, too ).

    But please note that, as Robert mentioned earlier, custom coding is out of the scope of our support, so we won’t be able to provide help you in implementing this.

    Best regards,
    Laszlo.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘After Login Hook?’ is closed to new replies.