The problem is that WP will redirect to the referrer when the authentication succeeds.
Fortunately, you can also supply _wp_http_referer
and it will be preferred over the HTTP Referrer, so we need to add a hidden field to the form and fill it with the permalink of the post in question:
echo str_replace('</form>', '<input type="hidden" name="_wp_http_referer" value="' . esc_attr(get_permalink(123)) . '" /></form>', get_the_password_form(123));
with 123 being the post ID.
Related Posts:
- Creating my own Admin Forms in a WordPress CMS?
- how to redirect to a custom password retrieval page
- Custom protected password page with ACF
- Intercept invalid email during lost_password
- How do I remove the eye icon that shows visibility on login screen and reset password screen
- Using transients to store captchas
- Add Div to Comment Form
- Adding custom field in all widgets, but at the top of the form, in admin area
- Custom search to display results within same page
- How Can I Move Data From Form 1 To Form 2
- Deep customization of wp-login.php
- Lost password empty field error redirect to custom login
- Custom Log In Screen – Disable password recovery [duplicate]
- Saving contact form 7 data into custom Table
- Woocommerce custom checkout form
- Custom login and registration forms
- Custom Form not generating URL
- How do I make Dynamic Student Admission Form?
- How to create multipage form and redirect to specific URL based on inpput?
- No plugin populate user information in to form
- How do I add a dropdown menu to a form?
- Password Protection issue
- Custom password set/reset link in same URL format as default does’t work
- How to automatically pull an information from a form field onto an other page?
- How to submit form data in the same page in WordPress without reloading the page?
- How to Password Protect whole site except for some subdirectories
- Custom dropdown search form that allows users to select option B based from Option 1
- Accountless password generation
- How to get name and email value from a custom form and add it to campaign monitor subscriber list?
- Custom user fields validation on registration
- Two searchforms with different categories/posts per page
- add unique code required to register
- Page template with custom html fields inside a content
- Is it posible to multiple entry value before submit Gravity forms?
- How to: Easily Move a WordPress Install from Development to Production?
- Is there a flowchart for WordPress loading sequence?
- Essential technical features for high-end WordPress web hosting? [closed]
- How to remove admin menu pages inserted by plugins?
- How to put logs in WordPress
- How to get the Date Format and Time Format settings for use in my template?
- Where are Additional CSS files stored
- Best Practices for Regression Testing WordPress Websites?
- Remove wrapping div and ul from output of wp_nav_menu
- What Is The Use Of map_meta_cap Filter?
- get post author id outside loop
- Custom Walker: how to get ID in function start_lvl
- Creative uses of WordPress [closed]
- Plugin Form Submission Best Practice
- How to *remove* a parent theme page template from a child theme?
- How do I make my child theme re-apply the settings that were customised when its parent was active?
- Multiple Inputs in a Customizer Control
- New WP_Customize API – how does it work under the hood?
- Embedding a SOAP Client into a WordPress Plugin?
- Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
- Update widget form after drag-and-drop (WP save bug)
- Data sanitization: Best Practices with code examples
- How to benchmark a WordPress installation? [closed]
- Should I delete the default themes?
- Moving WP install from local to live, what about wp_posts GUID?
- Modified wp.media.view.Settings.Gallery in Backbone JS, but editing doesn’t work
- Running Gutenberg React in Development Mode
- Prevent WordPress from automatically installing a new theme each year
- Can we use one WordPress installation for multiple databases, domains and content directories
- Is there a blank theme framework compatible with WP 3.0? [closed]
- Check for correct username on custom login form
- Plugin SVN & update API – how are plugins identified?
- Users with custom roles not showing in post author select box
- How to use more than 256MB of memory in the admin?
- How do register_sidebar() and get_sidebar() work together?
- How do you get formatted content of a post using the WordPress API?
- Add error message on password protected page
- Localization: I want the backend: english and frontend in defined language
- Are there any forks of WordPress (and what is different about them)?
- How to Change 404 page title
- Make Custom Metaboxes Collapse by Default
- WordPress Paginate $wpdb->get_results
- Custom maintenance page
- Add button to TinyMCE bar without creating a plugin
- Why do I get the timeout warning?
- How to add a new product type on woocommerce product types? [closed]
- How to include own css on wordpress tinymce editor?
- How to disable page delete
- add button to post edit page when post_status=publish
- how to override woocommerce specific loop or archive-product.php [closed]
- Modify existing plugin function using filter (without modifying the plugin directly)
- Rename UPLOADS folder with custom WP_CONTENT_DIR
- WordPress hook before inserting post into database
- Any post install tips after installing WordPress 3.0.1?
- Making Custom Fields Standard in the Admin UI
- Remove WordPress theme from a specific page
- Version Control: Entire site or just pieces?
- Getting a stack trace when an error occurs?
- Check for and enforce unique value in user-entered custom meta field in WP Admin
- Backup the Database and Restore from the Backup?
- get_pages() not ordering as it should
- Scaling a WP eCommerce site
- Custom Search Query
- How to remove comment section from page only , not from posts pages?
- Looking for a lightweight theme using WP3 new tags and features (not 2010) [closed]
- Why doesn’t WP_Image_Editor save images using the Filesystem API?