Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Changing login url

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:

  1. Is there a hook that runs after a user logs in?
  2. Is there a hook before the user is authenticated?
  3. Run javascript code after wp_login hook?
  4. How can I do customizations on login, registration and password recovery forms?
  5. after login that will redirect user role into a page
  6. Firing a function AFTER redirect
  7. How to get session token of current user in wp_login hook?
  8. Custom action on login and “remember me”
  9. Hook to change Logout url
  10. Send along login credentials with comment content
  11. Is it possible to add the_content filter upon login?
  12. wp_logout hook never triggered
  13. Updating user meta data from external link, user not logged in
  14. How to add a new link to the default register form’s footer links?
  15. Does wp_login hook fire on user registration?
  16. is_user_logged_in() doesn’t work after custom login and redirect
  17. Is there a way to send HTML formatted emails with WordPress’ wp_mail() function?
  18. How to get WordPress’ hooks/actions run sequence?
  19. Where can I find a list of WordPress hooks?
  20. Is there a save_post hook for custom post types?
  21. Where is the right place to register/enqueue scripts & styles
  22. How to know what functions are hooked to an action/filter?
  23. How to hook update_post_meta and delete_post_meta?
  24. Are there any hooks that alter the 404 logic?
  25. Difference between do_action and add_action
  26. WP Cron Doesn’t Execute When Time Elapses
  27. WooCommerce: change display order of product short description and price [closed]
  28. Why do some hooks not work inside class context?
  29. Difference between after_setup_theme and init action hooks?
  30. get $post in init filter or action?
  31. How reduce wordpress login session timeout time?
  32. Use wp init hook to call other hooks?
  33. How many times can I hook into the same action?
  34. How do I implement the WordPress Iris picker into my plugin on the front-end?
  35. How to intercept a 404 error
  36. Move excerpt meta box to above content editor
  37. Action hook for custom tax edit
  38. Trigger custom action when setting button pressed
  39. What is “all” in isset($wp_filter[‘all’])
  40. Whats worth using add_action when we can simply use add_filter?
  41. Is there a limit to hook priority?
  42. Please explain how these hooks work
  43. Add_action to wp_head via functions.php
  44. Hook after image is uploaded and image sizes generated
  45. Hook that fires when admin setting is saved
  46. add_action(‘wp_ajax_[action name]’, myfunction) problem
  47. WordPress auto login after registration not working
  48. What is the difference between update_post_meta and update_postmeta hooks?
  49. Hook ‘wp_enqueue_scripts’ priority has no effect
  50. Hook on trash post
  51. Hook *after* user password change?
  52. Auto-retrieve YouTube Image for Thumbnail?
  53. Which hook if user profile information is updated?
  54. How to remove action hook done in a plugin from functions.php in my theme?
  55. Hooks for trashing, deleting, saving, restoring custom post type
  56. How to change the default logout link on WordPress Admin
  57. Is there a WordPress core & plugins update action hook?
  58. Hook into WordPress update?
  59. trigger save_post event programmatically
  60. Implementing advanced add_* function wrappers
  61. Adding onload to body
  62. My add_action (wp_footer, ‘method’) is not calling?
  63. Do WordPress Core Filenames Work as Hooks?
  64. What is the earliest possible hook for safely using `is_front_page`?
  65. switch_to_blog(): Load textdomain
  66. How to call a REST endpoint when a post is published?
  67. __NAMESPACE__ with register_activation_hook
  68. Init action hook running late after PayPal’s return url?
  69. Can I hook inside another hook?
  70. Adding function directly vs using hook in function.php
  71. Are hooks called synchronously?
  72. How to check if which hook triggered the call to a function?
  73. How can I send to multiple Contact Form 7 recipients based on form input? [closed]
  74. Hook into wp_head(); in a plugin
  75. Send data to 3rd party api with wp_remote_post on wp_login
  76. is it possible to get the hook name in add_action?
  77. Hook for URL Request
  78. Masking logout URL
  79. How do I flush the rules after saving settings using the Settings API?
  80. Does anyone have a visual breakdown of core hooks and when they are fired?
  81. How to customize the WP admin default help contents
  82. What is the action hook for save media-form on gallery tab?
  83. handling login/logout redirects
  84. What hook is executed just after wp_query has been executed?
  85. Hide gutenberg option blocks
  86. The ‘user_has_cap’ hook seems to take two page loads to trigger
  87. How and where can we request new WordPress hooks to be added?
  88. Detecting post type within init action
  89. Disable block from editor based on post type
  90. WordPress Admin Tooltip hooks
  91. How can I tell if I’m on a login page? [duplicate]
  92. Difference between hooks Plugin_loaded and admin_int?
  93. Wp_update_post: Infinite loop even with remove_action solution, OOP
  94. Hook/notify when any option or setting is added or updated
  95. share login/logout sessions across two installs?
  96. Is it possible to save/modify a post without calling the “save_post” action hook?
  97. Change the footer text on the login page
  98. Which hooks is this? add_action(‘wp’,
  99. Change “You are now logged out” text
  100. Redirect logged in users if they are on a specific page
Categories hooks Tags hooks, login, logout
after refresh the id that shows correct in first time click, changes to 1
How can I add a zip code service availability checker in WordPress without Woocommerce? [closed]

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress