如何解决标题位置警告wordpress

Hi I want to create a simple login code to redirect each user to his own profile page.

I'm using a page "CleanPage" as a template for my php code.

I tried header Location and wp_redirect but both shows this error:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/general-template.php:1076) in /var/www/html/wp-content/themes/sydney/CleanPage.php on line 43

I wanted simple redirection like this:

header("Location: auth_customer.php?id=$userid");

Any help please?

The easiest one is to use 'meta refresh', try like this <?php echo "<meta http-equiv='refresh' content='0;url=auth_customer.php?id=$userid'>"; ?>.

Add an action to "wp_loaded" with a custom function and then make redirect within it.

<?php
add_action ('wp_loaded', 'ss_custom_redirect');
function ss_custom_redirect() {
    $redirect = 'http://example.com/redirect-example-url.html';
    wp_redirect($redirect);
    exit;
}     
?>

though I've already posted the link in the comment section above. I believe this should definitely solve your problem

<?php
add_action( 'send_headers', 'add_header_xua' );
function add_header_xua() {
    // your login logic or whatever should go here
    // ....
    header("Location: auth_customer.php?id=$userid");
}

Try this:

wp_redirect( home_url('/auth_customer.php?id='.$userid) ); exit;

You need to place the redirect function before get_header() / wp_head() for example:

if( //some logic here ) { 
  wp_redirect('page1');
} else {
  wp_redirect('page2');
}
...
get_header();