Jump to content
Sign in to follow this  
Jackey

Logout from both Vanilla and Wordpress

Recommended Posts

Jackey

Hi, I want to logout logout from vanilla and wordpress simultaneously, and found code that should log me out of vanilla.

setcookie('Vanilla', ' ', time() - 3600, '/', golfclub-stippelberg.nl ); unset($_COOKIE['Vanilla']);

Is there a way that I can include this by putting it into the functions.php as a filter to change the wp-login.php?

Share this post


Link to post
Share on other sites
Simon
Where do you need it to happen? Do you need this only on the login page?

Share this post


Link to post
Share on other sites
Jackey
Ideally I want it to happen after they click my logout button in the header of my site. [code] display_name . " ?»";?> [/code]

Share this post


Link to post
Share on other sites
Simon
just add : if ( ! is_user_logged_in() ) { your cookie stuff } before the other stuff?

Share this post


Link to post
Share on other sites
Jackey
Arghhhh... of course, brilliant! Doesn't matter if it does it every page load when not logged in. I get a error though: [code]Warning: Cannot modify header information - headers already sent by (output started at /home/wwwgolf/public_html/wp/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php:218) [/code] So I think I've inserted the code at the wrong place :( [code] function add_icons_to_branding(){ if ( ! is_user_logged_in() ) { setcookie('Vanilla', ' ', time() - 3600, '/', 'golfclub-stippelberg.nl' ); unset($_COOKIE['Vanilla']); } ?> display_name . " ?»";?>

Share this post


Link to post
Share on other sites
Simon
setcookie has to be before ANY output has gone to the screen wrap it in a add_action( 'init' ....

Share this post


Link to post
Share on other sites
Jackey
Bear with me Simon. This should go outside the function add_icons_to_branding? [code]add_action('init' if ( ! is_user_logged_in() ) { setcookie('Vanilla', ' ', time() - 3600, '/', 'golfclub-stippelberg.nl' ); unset($_COOKIE['Vanilla']); } ); [/code] or should it be: [code]add_action('init', setcookie('Vanilla', ' ', time() - 3600, '/', 'golfclub-stippelberg.nl' ); unset($_COOKIE['Vanilla']);[/code]

Share this post


Link to post
Share on other sites
Jackey
or does it work like this: [code] add_action('init', 'if_not_logged_in_log_out_vanilla') function if_not_logged_in_log_out_vanilla() { if ( ! is_user_logged_in() ) { setcookie('Vanilla', ' ', time() - 3600, '/', 'golfclub-stippelberg.nl' ); unset($_COOKIE['Vanilla']); } } [/code]

Share this post


Link to post
Share on other sites
Simon
Yea this needs to load before anything else #2 should do it

Share this post


Link to post
Share on other sites
Jackey
Have it boiled down to this : (without parse errors) [code] add_action('init', 'if_not_logged_in_log_out_vanilla'); function if_not_logged_in_log_out_vanilla() { if ( ! is_user_logged_in() ) { setcookie('Vanilla', ' ', time() - 3600, '/', 'golfclub-stippelberg.nl' ); unset($_COOKIE['Vanilla']); } } [/code] It either does not get executed, or the cookie code does not work. I thought I had this well figured out :( (with Simon's help of course...) I think I will put is to rest for today...

Share this post


Link to post
Share on other sites
Jackey
Maybe the action should be attached to another hook?

Share this post


Link to post
Share on other sites
Simon
It will get executed, maybe its just at the wrong time change init to wp it gets loaded earlier. There are even earlier hooks, full list here: http://codex.wordpress.org/Plugin_API/Action_Reference

Share this post


Link to post
Share on other sites
Jackey
Alas, tried almost every single one at no avail. (some clearly produce warnings that the execution is at the wrong time). I'm convinced the action is executed, but when I monitor my cookies in my browser the Vanilla cookie is untouched.

Share this post


Link to post
Share on other sites
Jackey
Thanks Simon... Learned a lot! Really! It is twice now that an Vanilla integration (on WordPress level) fails on me in the finishing stage of "dotting the i's". First proxy connect and now jsconnect. But since PageLines now provides the bbPress plugin integration I made a choice. (no multiple logins, no cookies)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×