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

Redirect after login to current URL

I need to do the next step:

To redirect my logout, I put the next code in functions.php

function out_home(){        
    wp_redirect(home_url());
    exit();
}
add_action("wp_logout","out_home");

In my header.php, to change the value of my URL in the login:

$URL_POSTLOGIN = add_query_arg(array(),$wp->request);
    function login_go_home($URL_POSTLOGIN){         
        wp_redirect($URL_POSTLOGIN);
        exit();
    }
    add_action("wp_login","login_go_home");

Maybe is not the best solution but in my case others codes fails.

Related Posts:

  1. How to change login labels
  2. error at login page in wordpress
  3. Show errormessages on wrong username/password on custom loginform?
  4. Unable to login after registration
  5. wp_login_form display no styled form
  6. wp_enqueue_script was called incorrectly
  7. Masking logout URL
  8. Logout/login redirect CSS issue
  9. How can I tell if I’m on a login page? [duplicate]
  10. Is it possible to use a forgot password url filter?
  11. redirect wp-login.php to another page
  12. Login using the password from protected pages
  13. How do I redirect upon login a specific user based on role?
  14. Logging in redirects to correct page but shows logged out content until forced refresh
  15. Remove default user registration, login and subscriber profiles
  16. is_user_logged_in not working to redirect only logged out users
  17. Members only site – still need the lost password page accessible
  18. Load .txt file for login_message in wp-login.php
  19. How can I get my Script to work on the Login page?
  20. Removing wp_login_viewport_meta
  21. Login Redirect if Logged in from Specific Page
  22. Unable to login using username
  23. When a user logs in, how can they view the website instead of the admin menu?
  24. WordPress PHP Conflicting User Sessions
  25. Get User Login Data (date, time… )
  26. Registration Hooks don’t appear to be working
  27. If user is logged-in display/hide something
  28. Secondary Menu and Logged In Users
  29. Prevent WordPress Automatic Logout
  30. Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
  31. Logout Redirect and also WP-login.php Redirect
  32. loginout function customization
  33. Add Login and logout buttons to top menu bar
  34. WordPress login set cookie that survive browser exit (wp_signon function)
  35. This code is supposed to only allow user to be authenticated if accountVerified is equal to 1, but it still allows user to be authenticated otherwise
  36. Prevent wp_signon redirect on failed login for ajax login
  37. How to redirect Subscribers on login to specific page, when logging in from a Page
  38. How to replace ACTION url from original wordpress login form?
  39. Allow logged in user to view a Page, else send to login screen and then redirect back to Page
  40. Re-style Login Form Whilst Keeping CSS Separate from Frontend CSS
  41. How to change form action of wp-login page with a function
  42. True email confirmation for registration (keeping unvalidated users from user table)
  43. Login functions
  44. WordPress permanently logging users out
  45. disable WP_error: authentication_failed
  46. How to request login for user but not for bots
  47. is_user_logged_in() isn’t working
  48. update_user_option not working as expected
  49. “Headers already sent” while trying to add a CSS file to my login page?
  50. Simple way to make most of my site private
  51. Redirecting after login except for a specific page
  52. Can You Set A Minimum Image Dimension For Resizing Images?
  53. How to create an array if ’empty’?
  54. wp_title() return random number
  55. Problems adding a new field to product in cart
  56. Auto Resize embedded videos player
  57. blank page with wp_get_attachment
  58. How to add javascript code into Divi child theme?
  59. Can site visitors view functions.php file?
  60. Parent category as WOOCommerce Categories widget title
  61. how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
  62. Woocommerce Display Discount On cart
  63. Check for $ _POST fields in a POST method form
  64. Getting value of variable from functions.php and debugging it
  65. Problem with my footer after changing WooCommerce Products Sorting [closed]
  66. Limiting WordPress Search function : Custom build
  67. Scheduled post delete – can’t pass the cron arguments
  68. How to show only specific category post by user role without plugin and restrict all other cats
  69. Why does echo on functions.php not yield result in source code?
  70. Wildcard 301 Redirect Using Theme Function
  71. Child theme remove parent filter in functions
  72. Changing the default view of “The Events Calendar” for mobile
  73. Child theme, how to cut the functions.php file into several classes?
  74. Set URL Parameter Post Layout As Default
  75. Styling WordPress login page – Can I change the markup on the login page?
  76. Why does my wp_enqueue_script() only insert the script for logged in users
  77. Modify content inside post before first publish
  78. Shortcode to output category description by passing ID
  79. Exclude admins from query get posts
  80. Pass an argument into a function to extract from array
  81. some profile informations like youtube link doesnt seem
  82. How do I make a custom “Read More Blogs” button for my blog page
  83. function class doesnt work
  84. I am trying to set post terms to a custom taxonomy
  85. Help using ShortCodes to style whole chunks of the post
  86. Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
  87. I’m creating a online store for my website, my aim is to add description to products in home page only how can i achieve it?
  88. how to increase connection time
  89. Shortcode to insert default text and change one word throughout it?
  90. get_locale() is different from $locale
  91. If click on Save/Publish change Post Status to Pending Review instead Publish
  92. modifying every other element’s class inside while loop
  93. Adding Custom Body Class for Page: Shop
  94. Its my first time trying to create a website , I got an error Please help
  95. Refresh page after login with litespeed cache
  96. How can I automatically delete comments that contain a URL?
  97. Run function for specific user only
  98. Pass post ID from archive template to functions file
  99. Replace theme function
  100. Competing Login Redirects – Need to be Combined?
Categories functions Tags functions, login, wp-login-form
How to add a shortcode to an HTML image tag
Customize url from the_terms

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