Title: Code not working logout
Last modified: July 1, 2020

---

# Code not working logout

 *  Resolved [cristoto](https://wordpress.org/support/users/cristoto/)
 * (@cristoto)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/code-not-working-logout/)
 * Yesterday, my snippets work without problems. But, today only work if the user
   is login into wordpress.
 * The problem is that I need the snippets work when the user is logout.
 * Can anybody help me?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcode-not-working-logout%2Fpage%2F2%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 16 through 20 (of 20 total)

[←](https://wordpress.org/support/topic/code-not-working-logout/?output_format=md)
[1](https://wordpress.org/support/topic/code-not-working-logout/?output_format=md)
2

 *  Thread Starter [cristoto](https://wordpress.org/support/users/cristoto/)
 * (@cristoto)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/code-not-working-logout/#post-13058742)
 * I tried use “Run everywhere” but not work.
 * The code only work when customer send form.
    Now you see that the screen appear
   empty when login with the test user. But the cookie isn’t storage and the header
   redirection don’t work.
 * I put a some var_dump() to see that the code enter into conditional and show 
   when execute each function.
    -  This reply was modified 5 years, 9 months ago by [cristoto](https://wordpress.org/support/users/cristoto/).
    -  This reply was modified 5 years, 9 months ago by [cristoto](https://wordpress.org/support/users/cristoto/).
 *  [Temyk](https://wordpress.org/support/users/webtemyk/)
 * (@webtemyk)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/code-not-working-logout/page/2/#post-13061690)
 * You need to make sure that all PHP code is executed in the snippet Everywhere.
   And you can output the form using a shortcode.
 * Also, don’t forget to abort the script `exit();` after calling `header()`
 *  Thread Starter [cristoto](https://wordpress.org/support/users/cristoto/)
 * (@cristoto)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/code-not-working-logout/page/2/#post-13061866)
 * I did it. I have the same problem with an authorizate user in wordpress work 
   but with I unauthorizate user don’t.
 *  [Temyk](https://wordpress.org/support/users/webtemyk/)
 * (@webtemyk)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/code-not-working-logout/page/2/#post-13061917)
 * `Warning: Cannot modify header information - headers already sent by (output 
   started at /var/www/html/wp-content/themes/Avada/header.php:14)`
    I see this 
   message on your site. So the theme outputs something earlier. Try executing the
   code using a hook:
 *     ```
       add_action('init', function(){
        //your php code
       })
       ```
   
 * [http://collabedit.com/44wfv](http://collabedit.com/44wfv)
    -  This reply was modified 5 years, 9 months ago by [Temyk](https://wordpress.org/support/users/webtemyk/).
 *  Thread Starter [cristoto](https://wordpress.org/support/users/cristoto/)
 * (@cristoto)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/code-not-working-logout/page/2/#post-13061951)
 * I tried but not work.
 * I think the warning isn’t the problem because with an authorize user (login into
   wordpress) the same code work. If I login with authroize login warning disappear.

Viewing 5 replies - 16 through 20 (of 20 total)

[←](https://wordpress.org/support/topic/code-not-working-logout/?output_format=md)
[1](https://wordpress.org/support/topic/code-not-working-logout/?output_format=md)
2

The topic ‘Code not working logout’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3475630)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 20 replies
 * 2 participants
 * Last reply from: [cristoto](https://wordpress.org/support/users/cristoto/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/code-not-working-logout/page/2/#post-13061951)
 * Status: resolved