I have a sign out on my site to log out of Wordpress

When logged out I would like to redirect uses to a different URL.

I'm using this in the functions.php

    add_action(' wp_logout ',' auto_redirect_external_after_logout ');
    function auto_redirect_external_after_logout(){
      wp_redirect( ' http://redirect-url ' );

and this in the header

    <li class="signOut"><?php wp_logout(); ?></li>

When I run this I get a long list of errors in the page

    Warning: Cannot modify header information - headers already sent by

To understand why your redirect isn't working, you should consider the mechanism it's using: the Location HTTP header. The problem here is that HTTP headers cannot be sent once you begin outputting content onto the page. Your task is to determine where that content is being output.

  1. Is it a plugin? Try disabling all your plugins and see if that fixes it.
  2. Is it your theme? Try switching to a different theme (modify it to use your logout hook) and see if that fixes it.

See also: http://codex.wordpress.org/FAQ_Troubleshooting#How_do_I_solve_the_Headers_already_sent_warning_problem.3F

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.