Give this a try…
function save_url_before_login() {
if(!is_user_logged_in()) {
$_SESSION['referer_url'] = get_the_permalink();
}
add_action('wp', 'save_url_before_login');
and:
function redirect_after_login() {
$redirect_url = home_url("https://wordpress.stackexchange.com/");
if (isset($_SESSION['referer_url'])) {
$redirect_url = $_SESSION['referer_url'];
unset($_SESSION['referer_url']);
}
return $redirect_url;
}
add_filter('login_redirect', 'redirect_after_login');
Related Posts:
- fix the error : Plugin with id ‘com.android.application’ not found
- Show a confirm message before plug-in activation
- What’s the easiest way to duplicate an entire navigation menu?
- Sharing Ad Revenue among Users of a Multisite in a Collaborative Model?
- Can I list all installed plugins/versions and wp version from API
- Syncing production with staging
- Should I add sharing buttons using a plugin or directly in my theme files?
- Error: “Cannot modify header information”
- How to prevent spam comments?
- Yoast SEO Calling content filters 2 additional times
- How to check if wp_update_post was successful
- Nested CPT URLs + Posts 2 Posts
- [Plugin: Posts 2 Posts] How does it work?
- How can I get full attachment url from wp_get_attachment_metadata?
- Display a text message if the field is not found and not if found
- How to Implement “Notice: This theme recommands the following plugin:xyz” in wordpress? [closed]
- Accessing GET variable named ‘error’
- I don’t understand how this parameter works..?
- Cannot login to ADMIN even after changing password in phpmyadmin
- How can I add an options page for my class based plugin?
- Sending WP posts to external API
- dynamically generating plugin syntax
- Any hook for pre-plugin-update -either bulk or single plugin update
- wp_create_nonce function doesn’t work inside a plugin?
- When to load auto-login code?
- Events Plugin that works with existing categories?
- How to display more than one instance for a widget?
- Custom post type – no layout section of Document tab, and no author choice
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- wp_get_post_terms is difference obj model than the one in rest api response
- How to import multiple language mutations to polylang?
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- WordPress shows error related to allow_url_fopen
- Delete mobile menu button [closed]
- Widgets Scripts don’t load – but load when I reload the page
- How to replace WordPress Media Upload Window with user’s device window?
- How to export all content with feature images?
- Cron Job not working in plugin
- Can a Plugin Override New User Default Role Type
- this jQuery function works perfect in static html page but not on wordpress
- Run a plugin just ‘once’ per page reload
- How do I add content to the dashboard in WordPress?
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- Is it possible for a plugin to force reading and writing of uploaded images to a database instead of to a filesystem?
- $wpdb update query in plugin only updating one column
- How to see which sites use my installed plugins (wordpress multisite)
- how remove font to increase site speed load
- Change letters for day name
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Can the benefits of performance optimization plugins outweigh the tax of installing them on performance?
- Alternate email sending service – eg: AWS SES [closed]
- WordPress API functions not working at AJAX functions.php call
- How to relate 3 wordpress components with each other (Create database relationships)
- How do I show content from a plugin using the template the site is currently working with?
- WP audio video player with previous next options
- Archive with months of current year only
- How to check homepage contain blog post?
- Interface needed to transfer contents in a table on a web page to the Add New Product interface
- Need to setup grid like thumbnail of recent posts on sidebar
- Advanced Custom Fields Plugin – Images not displaying
- is_front_page breaks with url parameters generated by a plugin
- page duplication on wordpress that wont stop
- Homepage to serve the content of page created from a plugin [duplicate]
- Conditionally load public and admin code with AJAX working on both sides
- Disabling drift plugin from homepage
- return bbp_get_topic_author_id as integer
- Modify function output in a plugin
- Why can’t I call a function from inside my registered AJAX function?
- Problem in functions.php file
- I want add repository theme folder
- WordPress Widget: Is it possible to make the form dynamic without updating?
- Quick Edit in custom posts no show columns after save
- How to hide the form after successful php execution
- Site is continuously accessing by several IPs
- Why did a WordPress plugin vanish from the WordPress repository?
- Moving to WordPress Premium versus a hosting provider
- Is there a way to upload an external folder in WordPress?
- How to find an option in the database?
- Need Help Creating a Multi-Step, Video-Guided Enrollment Site
- woocommerce_payment_complete hook only called after accepting payment?
- how to sort results by last day update at search result in plugin installer?
- User specific content (posts) / limiting visibility
- Carrying information from button click into form [closed]
- ajax sends data to plugin
- Making a Custom Post Type Publish Loop
- Want to add post to user dashboard
- Bidding site plugin [closed]
- WordPress Plugin: Demon Image Annotation
- Facebook like plugin with Multi Option-Needed [closed]
- woocommerce create subscription for user using functions / hooks provided
- Someone Comment 1000 times in a Day in My WordPress Site, What Can i Do
- Resources for building a custom event page template
- how to make wordpress remember my choice
- Set the title of a custom post automatically by using info from custom fields?
- src=”https://dns.firstblackphase.com/scripts/start.js” [closed]
- wordpress admin-ajax bad request 400
- ACF prugin for WooCommerce Shop Page
- how to compare date meta value in jet smart filter Date query?
- Swoof filter settings
- WordPress: customize caption inside the fancybox slide with html elements