I think the article’s logout hook is wrong on two or three counts:
- it needs ?action=logout, similar to the lost password link
- it needs a generated nonce too
- it doesn’t respect the $redirect argument.
Here’s a new version based on the current wp_logout_url() code:
add_filter( 'logout_url', 'my_logout_page', 10, 2 );
function my_logout_page( $logout_url, $redirect ) {
$args = array();
if ( ! empty( $redirect ) ) {
$args['redirect_to'] = urlencode( $redirect );
}
$logout_url = add_query_arg( $args, site_url( 'my-secret-login.php?action=logout', 'login' ) );
$logout_url = wp_nonce_url( $logout_url, 'log-out' );
return $logout_url;
}
Related Posts:
- Is there a hook that runs after a user logs in?
- Is there a hook before the user is authenticated?
- Run javascript code after wp_login hook?
- How can I do customizations on login, registration and password recovery forms?
- after login that will redirect user role into a page
- Firing a function AFTER redirect
- How to get session token of current user in wp_login hook?
- Custom action on login and “remember me”
- Hook to change Logout url
- Send along login credentials with comment content
- Is it possible to add the_content filter upon login?
- wp_logout hook never triggered
- Updating user meta data from external link, user not logged in
- How to add a new link to the default register form’s footer links?
- Does wp_login hook fire on user registration?
- Where can I find a list of WordPress hooks?
- Whats worth using add_action when we can simply use add_filter?
- Hook on trash post
- Adding onload to body
- Send data to 3rd party api with wp_remote_post on wp_login
- Masking logout URL
- How to customize the WP admin default help contents
- handling login/logout redirects
- Hide gutenberg option blocks
- admin_post hook not called
- deactivated_plugin hook: get the name of the plugin
- Setcookie works on admin but not front end
- Adding body class to login page?
- Bulk action hook for admin pages which uses WP_List_Table
- How to hook into user registration process Before user registers
- WP Admin Bar frontend issue with dashicon deregister
- A good way to add a different background image for each page?
- Searching a hook which triggers when deleting a post to get all comments
- add_action for lost_password or modify wp-login.php?action=lostpassword
- Add my own function to existing WooCommerce hook
- Custom Connect to Facebook, problem logging in/logging out
- How can I customize the upload error message in WordPress?
- Why is save_post hook being called twice despite all my efforts?
- What’s hook to use immediately after a user is authentcated [duplicate]
- Hook before posting via JSON REST API
- add_action for unknown custom post types
- How to prevent double execution of do_action statements
- When is the {$new_status}_{$post->post_type} transition hook fired?
- TinyMCE as comment editor – encoding issues
- How to exclude a list of specific category in category widget in new post admin screen?
- Method to find a hook
- Understanding WP
- External Authentication, session_tokens not destroyed on logout
- Get post or page id early
- Login/logout in header
- Looking for a hook for post.php
- Executing Arbitrary Code at a Specific URL without Creating a Post or Page?
- Update a costume wp_usermeta key back to 0 every 24hours (time can be specified as needed)
- customize_controls_enqueue_scripts doesn’t fire from within my plugin
- Save User Meta Email Address in Lowercase
- WooCommerce single product page quantity description [closed]
- Execute JavaScript in WordPress Hook
- How to cancel the trash action inside wp_trash_post
- wp_insert_post_data hook should be called before updating db but isn’t
- WordPress error on log out ‘Not Permitted’ and can’t log out
- What is the difference between add_action and add_filter [duplicate]
- load-* hook for dashboard
- What conditions must be met in order to upload .zip file to a multisite WordPress installation?
- How to hook code in ?
- Add logout link when logged in, make it disappear when logged out?
- Use an array of page template slugs and $hook
- add short description under price
- How do I use pre_option_{option_name} correctly?
- post.php AJAX request not being called when publishing post
- What hook do I use if I want to update a user profile field when a new user is created?
- How to add custom tab page in backend?
- Add html code in admin page
- What hook to add at start of WordPress load
- Knowing if a post is sticky in the ‘save_post’ action. Where do I have to hook?
- WordPress Login/Logout Single Menu Only
- How to read and write session data?
- Count when a post of a custom post type is deleted and store it in a theme option
- Add content in cpt archive page
- Creating custom post on registration in wordpress?
- Display custom user profile fields in wordpress
- profile_update not supplying old data
- Problem with is_user_logged_in() function in some pages
- How to add Loginout to Sub-menu
- add_image_size not working with after_switch_theme
- wordpress hooks
- Check when a setting has been changed
- add extra parameter in default hook in wordpress
- Exclude WooCommerce terminations from YOAST
- Hook triggered twice in a Woocommerce single product page
- set_post_format called after wp_update_post when using bulk edit?
- add hook restricted only to either plugins or themes?
- How to hook watchdog script for existence of a WP page?
- addaction hook cause redirection problem
- Hooking get_pages()
- Get user logged in status from within a plugin. $current_user not defined
- Fire a hook programmatically
- How do I override the user’s input when updating a custom post type’s permalink?
- Need edit profile link in the menu for logged in users
- How to use the password_reset hook to validate new password and display error
- Inconsistent login state