Getting User email on logout. wp_logout

wp_get_current_user() will never work in this hook, because, wp_logout action fires after user is logged out: session destroyed, cookies cleared and current user is set to 0.

But wp_logout action recieves $user_id. I will give you a working example, because I do not familiar with your custom functions.

//pass $user_id as argument
function mmd_JudgeLogoutCheck($user_id)
{
    $user  = get_userdata($user_id); 
    if ( $user instanceof WP_User  )  
    {  
        //user email available here
        die($user->user_email);  
    } 
}

//here last argument should be one
add_action( 'wp_logout', 'mmd_JudgeLogoutCheck', 10,1);

Leave a Comment