Login – Logout ,usermeta update

This topic contains 5 replies, has 2 voices, and was last updated by  Pie Register 3 years, 8 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10003903

    Andrea Bettelli
    Participant

    Hi,
    Please … I would like to know how and where you could work with the code, to get the updating of some user_meta at the moment of the Login and some other user_meta at the moment of Logout.
    Login and Logout from your link in the widget.
    Thanks
    Andrea

    #10003915

    Pie Register
    Keymaster

    Hello Andrea,

    You can use following hooks on Login
    wp_login
    piereg_admin_login_before_redirect_hook
    piereg_user_login_before_redirect_hook

    For logout PR uses wp_logout() so you will have wp_logout to hook yur function.

    Thanks

    #10003919

    Andrea Bettelli
    Participant

    Hi Hasnain Abbas,
    please, may I ask you to write a complete example for update_user_meta (pippo) for the event of Login and a complete example for update_user_meta (pappa) for the event of Logout functions?
    Thank you!
    Andrea

    #10003933

    Pie Register
    Keymaster

    Hello,

    Here’s the example:

    for Login:
    add_action(‘wp_login’,’myCustomLoginHook’, 10, 2);

    function myCustomLoginHook($username,$userObject){
    //Do Something
    }

    for Logout:
    add_action(‘wp_logout’,’myCustomLogoutHook’);

    function myCustomLogoutHook(){
    //Do Something
    }

    Hope it helps

    Thanks

    #10003936

    Andrea Bettelli
    Participant

    Hi Hasnain Abbas,
    That’s work fantastic!
    Thank you very much!

    Sorry … have you the time for explain me what are the last 2 numbers of the code?
    add_action(‘wp_login’,’myCustomLoginHook’, 10, 2);

    Why is there on the Login function, but not on the Logout function?
    Thanks a lot again, gentleman!
    Andrea

    #10003939

    Pie Register
    Keymaster

    I am glad you got it working.

    Well, those are arguments number that are being passed to your custom function.
    in logout hook there is no param to pass.

    Your input matters. Please give us your favorable rating at WordPress Just please click here.
    https://wordpress.org/support/view/plugin-reviews/pie-register

    Thanks

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.