Wp_redirect () function not working in WP admin
I will try the following code to redirect to wordpress admin.
if(isset($_POST['submit']))
{
wp_redirect('admin.php?page=job-creation');
}
i also try wp_redirect('admin.php?page=job-creation');
instead
wp_safe_redirect('admin.php?page=job-creation');
and
header('location: admin.php?page=job-creation');
All codes work fine on localhost. but it doesn't work on the internet (www.example.com).
Help me.
source to share
I think this is for your web server configuration, you cannot use the header function every where in the code. Instead of using a header, use this:
print('<script>window.location.href="admin.php?page=job-creation"</script>');
This is simple javascript code to redirect to another page.
UPDATE
For more usage information header
visit this question
source to share
Use this code in the plugin that should activate b.
function callback($buffer) {
// modify buffer here, and then return the updated code
return $buffer;
}
function buffer_start() {
ob_start("callback");
}
function buffer_end() {
ob_end_flush();
}
add_action('init', 'buffer_start');
add_action('wp_footer', 'buffer_end');
source to share
First, you should always exit
after use wp_redirect
.
Second, you must provide an absolute URI. Use admin_url
for this.
if( isset( $_POST['submit'] ) ){
wp_redirect( admin_url( 'admin.php?page=job-creation' ) );
exit;
}
source to share