Adding this snippet to the functions.php of your wordpress theme will redirect visitors to the page they were viewing after logging in.
if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['login_location']) && !empty($_POST['login_location'])) ) {
function my_login_redirect() {
$location = $_SERVER['HTTP_REFERER'];
wp_safe_redirect($location);
exit();
}
add_filter('login_redirect', 'my_login_redirect', 10, 3);
}
Related Posts:
- Restrict content access to logged in users
- Redirect all pages to the custom login page except for the registration page
- Change the login button on the login page
- Custom ReCaptcha Login
- What is the proper way to apply the login_form_bottom filter?
- How to override wp-login.php
- Remove Links from Login page
- Need logged in users returing to site redirected to a separate page
- How to let a single post have its own domain name
- setting a specific home page for logged in users
- Redirect members to custom page upon logging in through WP admin
- Change “logged in” link in (you must be logged in to post a comment)
- Customizing the default logout page of WordPress
- How do I remove the eye icon that shows visibility on login screen and reset password screen
- Hide Login information in Account settings in Buddy Boss
- Custom Login and Registration form in Ajax
- Last time a user logged in
- How can I allow access to multiple users, using the same login, at the same time?
- WordPress custom login page
- Turn off redirect to canonical domain (or host website on any hostname)
- Adding a login form that concatenates three fields into a username
- Search result page redirect ex.com/?s=searchterms to ex.com/searchterms
- Properly customizing login/register form
- How to add an extra variable to login and authenticate it?
- Login/Logout Session Sharing – Multiple WordPress Installations
- Custom login with external provider iframe and data object
- Deep customization of wp-login.php
- User can not login
- Lost password empty field error redirect to custom login
- Custom Log In Screen – Disable password recovery [duplicate]
- Multi-site User Sessions
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- A truely custom login page?
- Switch between WordPress websites easy for an end user
- Lost password and back to blog in same line
- I w’d like to know If there are simple solutions to integrate other CMSs to wordpress
- How do I create a root link in wordpress to a PDF file?
- Custom login and registration forms
- Showing different pages depending on a cookie value
- URL and Site title outputting on Login page
- Is it possible to integrate a custom login feature with wordpress?
- How to change the login page without a plugin and not only customizing logo and text around the form?
- Removing “Failed” query argument upon successful login
- Validate user login in php
- how to change the url rediction of the woocommerce login page of the flatsome theme for my own in wordpress?
- Block direct access to thank you pages
- How to change Login default blue admin color?
- Latest update broke my custom login CSS
- Custom Route Returns 301/Passing Variable from Input
- Trouble with custom login page
- Wrap WordPress Login Form in custom Div
- Custom login doesn’t stay
- Check get_post value after wp-admin login
- where can i find the login page in wordpress and add my header to it
- Change the default WordPress image on the dashboard login to a custom image [duplicate]
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Allow arbitrary text after page URL
- Pass the post ID
- How to request login for user but not for bots
- Show Site Name on WP login screen
- how to manage Session in WordPress using custom login?
- How to stop login for SPECIFIC users BEFORE a specified date
- Redirection after Category Change for Custom Structure
- WordPress objects class reference
- How do you add pages on a staging server, and then move them over to production
- Any Hook Called When Post Becomes Published?
- Automatically wrap post image in div
- Custom php file in wordpress
- Display tags with a twist
- How to add another page in appearance tab of admin panel?
- WordPress change author email notify message?
- add JS to multiple plugin admin pages
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- Follow me for WordPress blogs (multi-authors)
- Pagination Issues using WP_Paginate Plugin
- custom theme ,add media not showing images in media library
- Get Image from Media Library with the Title
- Add a searchbox to the body of a page
- Best way to allow overwriting images shipped with the plugin?
- Static Front Page settings – distinguish between Front page and Post page
- How to print Array values of custom Fields Meta?
- Customizer JS API get value of customizer field
- Hide content and functions from specific user roles
- Translating (WooCommerce) placeholder text
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Infinite loop when logging out using custom login form
- How can I setup a development environment which auto refresh page when code have changed [closed]
- I want to use a product thumbnail completely different than the product image
- How can I edit the WordPress menu link to allow fb: instead of http
- Fixed bottom menu on mobile doesn’t work on search included in Child Theme of Storefront
- Change Dashboard menu position?
- Get site ID from attachment url?
- duplicate featured image functionality in custom meta box
- How to automatically pull an information from a form field onto an other page?
- Move text from the side of image to below image [closed]
- login page not working [closed]
- Custom terms in custom category taxonomy
- Customize TinyMCE Buttons
- Instead of Custom CSS Theme CSS is loading
- Custom Post want button to add image and save in Postmeta