0

for page redirection in wordpress plugin m using php header function

my code is

$URL = admin_url('admin.php?page=myaccount&success=yes');
header("location:".$URL);
exit();

it gives me error like this.

Warning: Cannot modify header information - headers already sent by (output started at /home/fusionmark/public_html/wp/wp-admin/includes/template.php:1877) in /home/fusionmark/public_html/wp/wp-content/plugins/JVZoo/includes.php on line 258

Bruce
  • 1,647
  • 4
  • 20
  • 22
Nikhil Musale
  • 340
  • 1
  • 13

2 Answers2

0

use wp_safe_redirect() function

 $redirect = admin_url('admin.php?page=myaccount&success=yes');
 wp_safe_redirect($redirect);
 die();
sarath
  • 698
  • 6
  • 20
  • Warning: Cannot modify header information - headers already sent by (output started at /home/fusionmark/public_html/wp/wp-admin/includes/template.php:1877) in /home/fusionmark/public_html/wp/wp-includes/pluggable.php on line 1178 – Nikhil Musale Jun 18 '15 at 04:20
  • can I know why are using this redirection ? where you putting this code – sarath Jun 18 '15 at 04:23
  • after performing some action ,i want to redirect page to dashboard – Nikhil Musale Jun 18 '15 at 04:25
0
$URL = admin_url('admin.php?page=myaccount&success=yes');
header("location:".$URL);
exit();

instead of use:

$location = admin_url('admin.php?page=myaccount&success=yes');
wp_redirect( $location);
exit;

whatever redirect hook you can use but it place before get_header();

Samyappa
  • 535
  • 2
  • 11