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();
}
});