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 redirect all HTTP requests to HTTPS
- What does HTTP/1.1 302 mean exactly?
- Objective Best Practices for Plugin Development? [closed]
- add_menu_page() with different name for first submenu item
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How to include PHP files in plugins the correct way
- How can I add an image upload field directly to a custom write panel?
- A tool to analyze rewrite rules? [closed]
- Difference Between Filter and Action Hooks?
- framework for plugin/theme options panel? [closed]
- Creating a table in the admin-style?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Settings API with arrays example
- How to get the path to the current theme?
- How to make a plugin require another plugin?
- ajaxurl not defined on front end
- What process do you use for WordPress development? [closed]
- What’s the difference between term_id and term_taxonomy_id
- Should I use wpdb prepare?
- Why does WordPress use outdated jQuery v1.12.4?
- Post meta vs separate database tables
- Is there any plugin development framework
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How to add a javascript snippet to the footer that requires jQuery
- Enhance Media Manager for Gallery
- How do I create a custom role capability?
- How do I add CSS options to my plugin without using inline styles?
- How do i best handle custom plugin page actions?
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- Automatically determine minimum WordPress version required for a plugin?
- What is the advantage of using wp_mail?
- How to make a WordPress plugin translation ready?
- How many times will this code run? (or, how rich is grandma?)
- How to create an API for my plugin?
- Is it ever okay to include inline CSS in plugins?
- Plugins in symlinked directories?
- How to override existing plugin action with new action
- How to include a file using get_template_part() in a plugin?
- Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1
- How to store username and password to API in wordpress option DB?
- body_class hook for admin pages
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Is it mandatory to use $wpdb->prefix in custom tables
- add_action hook for completely new post?
- Why does WordPress add 0 (zero) to an Ajax response?
- What should I use instead of WP_CONTENT_DIR and WP_PLUGIN_DIR?
- How to enqueue JavaScripts in a plugin
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Plugin Form Submission Best Practice
- How to redirect to settings page once the plugin is activated?
- Is get_option function cached?
- Should Plugin Folders Include a Blank index.php File?
- Unit testing for plugin development
- Methods of Integrating Plugin Data with Themes
- What is the wordpress wp-includes folder for?
- WordPress Update Plugin Hook/Action? Since 3.9
- How to include jQuery and JavaScript files correctly?
- How come `wp_options` table does not have an index on `autoload`?
- PHP error with shortcode handler from a class
- Update Option Stored in Multi-Dimensional Array
- check if Gutenberg is currently in use
- Best way to abort plugin in case of insufficient PHP version?
- WordPress Plugin Development – Headers Already Sent Message
- WP 3.3 How to Add Menu Items to the Admin Bar?
- dbDelta not creating tables
- Custom Widget function in Plugin not working?
- Passing arguments to a admin menu page callback?
- Single functions.php or split into many small files?
- Get page content using slug
- $_POST form request with admin-post
- How to fork a plugin?
- How can I configure Docker for developing and deploying a custom theme?