Created
September 12, 2022 13:14
-
-
Save yawalkar/27a581126290bad83024b63f3fb9692a to your computer and use it in GitHub Desktop.
Get user details on logout with custom action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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