wp_die()
terminates the script execution and sends itself a 500 status header (wich can be altered by the third parameter). So you need to send the Refresh
header before the wp_die()
call. I also recommend to print the redirect location to the body because it’s up to the client to respect the refresh header.
if ( $condition ) {
$location = 'http://pm.dev';
$timeout = 5;
$message="You will be redirected to <a href="" . $location . '">' . $location . '</a>';
$title="Your title";
$status = 303; # this might be debatable
header( 'Refresh: ' . $timeout . ';' . $location );
wp_die( $message, $title, array( 'response' => $status ) );
}
(I’m not sure about the correct status code.)
Note: As this code sends HTTP Headers, there must no other output sent to the browser before this code.
Related Posts:
- Which hook should be used to add an action containing a redirect?
- Making a plugin file accessible via url rewrite?
- Clarity needed on usage of multiple 403 forbidden header() functions at the beginning of the plugin files
- Custom admin_notices Messages Ignored During Redirects
- Pages 404 in wordpress
- How can I change HTTP headers only to posts of a specific category from a plugin
- How to redirect to action on custom page within admin section
- Change template dynamically
- On cliking add new post redirect user to a custom page first
- Show custom data instead of 404
- Why does wp_remote_post returns an empty body response on certain endpoints?
- Force HTTPS 301 redirect with hook
- Add a new confirmation page before saving
- How to redirect to login page when user not loggedin on a particular page
- Is there any way to pass messages from a script to a redirect target in a hidden fashion?
- Custom payment method after payment user is logged out on thank you page
- How to Login a User inside a Plugin and Redirect to page?
- Add New Button in Admin Panel
- Redirection from a specific page for users logged in but not with membership
- Redirect WooCommerce checkout to cart
- Creating a return url for getting data from external api
- redirect_to how to make it simply work with get parameter or similar?
- Unable to link CSS file
- Any way to make Apache’s internal redirect work?
- How to load another page file of my custom plugin file
- Redirections the right way inside a plugin directory
- Is it safe to use PUT and DELETE requests
- Custom rewrite, url path with parameters to a page
- How to add a javascript snippet to the footer that requires jQuery
- Enhance Media Manager for Gallery
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- How to create an API for my plugin?
- Plugins in symlinked directories?
- How to use PanelColorSettings in custom Gutenberg block?
- Is there a way for a plug-in to get it’s own version number?
- How to add tab which is visible only in admin side of product in woocommerce? [closed]
- How do I print a notice only on certain admin pages?
- Hook the Keydown Event in the TinyMCE Post Editor
- Create a clickable name in WP_List_Table for Plugin Admin
- Plugin development without Theme adjustments?
- How to Make a Category Always Selected?
- WordPress Settings API: saving multiple rows of similar data
- Modify how gallery.js builds the shortcode [gallery ...] in tinyMCE?
- How to use is_multisite() in a must-use-plugin?
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- DataBase connection problem with PHPUnit and WordPress
- Modify a Free Plugin available on wordpress.org & include with my Premium Theme? [closed]
- StackExchange clone using WordPress?
- Custom url for a plugin page add_rewrite_rule WordPress
- Is there a way to ensure plugin script loads before another script?
- Custom attribute type not displaying terms in edit product – WooCommerce
- Verify if user is wordpress logged in from another app since wordpress 4.0
- how to get link of added document with a post
- Doubts about the use of metadata and how this can affect performance on WordPress
- How can I replace content in the WP Admin area before an admin page is rendered?
- When is the proper time to minify css and js with git workflow?
- Get draggable widgets on Edit Post page
- Plugin that saves form data
- how to invoke wordpress API from other existing PHP system
- Warning: include(): https:// wrapper is disabled in the server configuration by allow_url_include=0
- How to get the post excerpt using post object?
- jquery & ajax sending data to php
- How to import the css in the plugin admin area?
- Using add_sub_menu to put into Appearance Section
- jquery in wordpress plugin with depdendency
- Replace first occurence of a word with link [closed]
- Converting core modification to a plugin
- wordpress automatic update does not run
- Ajax +wordpress onClick link redirect to new page and create html content
- Adding filter to the title without affecting the menu title
- How to show multiple instances of the WP125 Widget?
- How can the_excerpt (or equivalent) be called on a category description?
- How to call a function from a shortcode function in an oop plugin
- Posts form with AJAX request – Plugin development
- Multiple TinyMCE on button click is initialized and appended but why only last one is writeable?
- How to create a custom post-new.php page for plugin , no wp menu
- How to create a custom WordPress page with my plugin?
- Want to know how to reveal a WordPress theme, considering the theme name is hidden?
- Where to add functions and code snippets in wordpress
- How to re-render inspector controls?
- Sanitize WordPress Array Input?
- WC REST API Error Handling
- Shortcode content is not showing. Only the [shortcode-tag] is showing
- How to remove the WooCommerce Product->Category thumbnail from admin [closed]
- Creating a virtual page without exit
- Plugin Development – Call to undefined function comment_exists()
- Replace “content-area” of themes 404 page with plugin?
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- WordPress doesn’t create table on plugin activation
- Create Customization panel for Plugins not for theme
- Allow user to change homepage
- Custom signature appears twice on page
- wp_mail links are dead
- List Available Templates for Current Theme in a Plugin
- Adding Third Post Box Column: postbox-container-3
- Get custom wp_query search results to appear on search.php
- WooCommerce custom payment gateway
- Multi-part form and wp_redirect()
- Sharing changes to a post (preview changes) with another user
- Display months on a drop down calendar as TEXT instead of Numbers