You will need to use a hook (such as init
or admin_init
) to detect whether a condition has been met. For instance, the existence of a certain querystring variable (which can be a url encoded url, if you like).
When the condition is met, use wp_safe_redirect()
(and optionally exit()
) to redirect to the URL you want. You can either hard-code that URL or fetch it from the querystring if your button passed it along as a urlencoded variable.
Hypothetical example (PHP 5.3+ syntax):
add_action('init', function(){
if ( isset($_REQUEST['redirect_to']) ) {
wp_safe_redirect($_REQUEST['redirect_to']);
exit();
}
});
Related Posts:
- Best Practice for PHP
- Adding “Remember Me” in custom login
- Using wp_send_json to return HTML
- WordPress URL Rewrite not working
- WordPress Infinite Scroll without using any plugin
- Add post class to the TinyMCE iframe?
- How to remove a metabox from menu editor page?
- How to Join two tables from separate databases within WordPress
- How to find objects by terms
- Bypass .htaccess when using download_url
- wp_remote_get returns an error for valid URL
- Install will not load: PHP does not have MYSQL installed
- Constructing a custom login form using ajax
- Error when requesting password reset email – wp authentication
- How to do conditional publishing?
- New Plugin Review
- Create custom blocks for bootstrap
- How to get the post_id from postmeta
- Anyone can register via backend
- How to get to a specific position in wp_query?
- Preferred Method of debugging a wordpress SQL calls?
- Displaying NextGen Gallery using value from meta not working
- Taxonomy linked to pages
- Checking for new message using AJAX and PHP. Server overload?
- WordPress Scheduled Event Request Blocking
- jQuery not defined
- dynamic page in WordPress
- How to use my style.css file outside of wordpress subdomain?
- How to sort posts based on the value (number) of a post’s metadata?
- Pagination of custom mysql in wordpress
- Automatically create child pages and grandchild pages when saving a (parent) page
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- How do I start using an external API and PHP for a WordPress.org page?
- Unread Repeater field IMG alt not working
- How to add an arrow to menu items has submenus
- Is it possible to create a wordpress database with php code?
- Script to browser problem PHP
- wp_nav_menu returns menu list in ascending order. How can I arrange the menu same as dashboard menu
- Customizer: Category Select Sanitize
- action theme mailchimp subscriber fields
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- How to retrieve the sender email with wp_mail()?
- WordPress update_post_meta updating with empty meta_value field [closed]
- Call to undefined function mysql_connect() After upgrading PHP 7.1 to 7.3
- Non-Closing PHP Query in WordPress Loop
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Is it save to use eval for a jQuery callback method coming from the database?
- Need oop for wordpress theme? [duplicate]
- Display Youtube Time Automate from Key
- What is the best way to define constant options for a theme?
- An audio player that showcase a random song from playlist every 24h [closed]
- Use value from Ajax call in PHP function
- wp_localize_script() and JavaScript namespaces
- extract serialized array to use for wp-query
- Help Fallback (thumbnail)
- PHP Contact form
- Extract and display user infromation on an automatically created page
- Why won’t this wpdb get_results query return results?
- Why doesn’t global $wp_query not get hooked?
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- How can I assign separate stylesheets to different pages?
- Using multiple variables to assign categories to an array
- Show Custom Menu Name in WordPress 3
- Add a custom WooCommerce settings tab with sections
- Checking page before applying image restrictions while uploading
- AWS Lightsail WordPress – connect to database on instance using mysqli
- No more get_option(‘date_time’) in WordPress 5.5?
- Create category after theme setup and modify the default one
- Using wpdb to connect to a different database is not working
- PHP error on local server install
- how to use 2 index.php file One for mobile and one for desktop
- ACF under category name in shop page [closed]
- Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)
- Using $this with an anonymous function in filters
- Dynamic_sidebar load in string makeup
- Post Meta statement?
- Prepared DB Query from _POST array
- How to include non-users in wp-admin redirect?
- Add disclaimer before certain posts and pages
- Use Custiomizer to setup meta theme color tag
- Static home page ignored
- How do I routinely extract the thumbnail of the most recent post?
- Click to expand menu
- WP_Post is not from correct array
- Showing custom field contents without listing description
- Using ‘array’ method in wp_nav_menu causes it to disappear
- If I define a variable in header.php, how do I make it available to templates?
- How to add together (get the sum) a field from all author’s posts
- two body tags on all WP pages regardless of theme
- Load php function with AJAX on modal window
- Remove /category/ from category (archive) page URLs (without using a plugin)
- JSON Object Value Show Undefine
- Display biography post for today’s birthday person
- ‘This Field is Required.’ is Not Displaying on CF7 [closed]
- REST API custom endpoints for metaboxes
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- generate excerpt from the part of big text dump that contains keyword
- How to sort search result by post_title, then by post_content
- Custom Admin Menu Report for Specific User ID
- how can i link threejs in my functions.php file in understrap theme