5

I will try following code for redirect in wordpress admin.

if(isset($_POST['submit'])) 
    {
wp_redirect('admin.php?page=job-creation');
}

i also try wp_redirect('admin.php?page=job-creation'); instead of

wp_safe_redirect('admin.php?page=job-creation'); 

and

header('location: admin.php?page=job-creation');

All codes are working fine in localhost. but it does not working in online(www.example.com).

Help me anyone.

Boopathi Rajan
  • 1,212
  • 15
  • 38

4 Answers4

8

I think this is for your web server configuration, you can't use header function every where in code. Instead of using header, use this :

print('<script>window.location.href="admin.php?page=job-creation"</script>');

This is a simple javascript code for redirect to another page.

UPDATE

For more information about using header visit this question

Community
  • 1
  • 1
Saman Gholami
  • 3,416
  • 7
  • 30
  • 71
2

Use this code in that plugin which must b activate.

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');
0

Firstly, you should always exit after you using wp_redirect.

Secondly, you should specify an absolute URI. Use admin_url for that.

if( isset( $_POST['submit'] ) ){
  wp_redirect( admin_url( 'admin.php?page=job-creation' ) );
  exit;
}
RRikesh
  • 14,112
  • 5
  • 49
  • 70
0

Try to use ob_start() function before redirecting if url is correct.

Rakesh kumar
  • 135
  • 6