Skip to content

Instantly share code, notes, and snippets.

@yawalkar
Created September 12, 2022 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yawalkar/27a581126290bad83024b63f3fb9692a to your computer and use it in GitHub Desktop.
Save yawalkar/27a581126290bad83024b63f3fb9692a to your computer and use it in GitHub Desktop.
Get user details on logout with custom action
add_action( 'wp_logout', 'flowmattic_custom_logout' );
function flowmattic_custom_logout( $user_id ) {
$user_details = array();
$current_user = get_user_by( 'ID', $user_id );
$user_details['username'] = $current_user->user_login;
$user_details['user_email'] = $current_user->user_email;
$user_details['user_first_name'] = $current_user->user_firstname;
$user_details['user_last_name'] = $current_user->user_lastname;
$user_details['user_display_name'] = $current_user->display_name;
$user_details['user_id'] = $current_user->ID;
do_action( 'flowmattic_custom_logout', $user_details );
}
To start your workflow after the user logged out and get user details, use the following steps -
- Add the Plugin Actions module as trigger
- Enter the action name as *flowmattic_custom_logout*
- Add the above code to your wp-content/mu-plugins/ directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment