LogOut button only if logged in in front end menu widget

To add a menu item to the end of a nav menu you can use the wp_nav_menu_items hook. Combine that with is_user_logged_in() and you ought to have it. function add_last_nav_item($items) { if (!is_user_logged_in()) { return $items .= ‘your login link’; } } add_filter(‘wp_nav_menu_items’,’add_last_nav_item’); As far as translation, I assume that qTranslate uses the standard translation … Read more

What is difference between logout and switch off?

You have the plugin User Switching installed From their FAQ: What does “Switch off” mean? Switching off logs you out of your account but retains your user ID in an authentication cookie so you can switch straight back without having to log in again manually. It’s akin to switching to no user, and being able … Read more

Logout redirects to /forums/

I discovered the Hikari Hooks Troubleshooter (http://hikari.ws/hooks-troubleshooter/) this weekend to find what plugins were loading my header with competing open graph metadata. Enable it, and visit the frontend. There will be a modal dialog over your site which should list the hooks into wp_logout. One of these will be the offending plugin. If you’re still … Read more

Logout using link (without nonce)

This will disable nonce checking for logging out – on your head be it: add_action( ‘login_form_logout’, function () { $user = wp_get_current_user(); wp_logout(); if ( ! empty( $_REQUEST[‘redirect_to’] ) ) { $redirect_to = $requested_redirect_to = $_REQUEST[‘redirect_to’]; } else { $redirect_to = ‘wp-login.php?loggedout=true’; $requested_redirect_to = ”; } /** * Filters the log out redirect URL. * … Read more

wp_logout not redirecting using wp_logout_url() and wp_redirect()

The correct method for changing the logout redirect is the logout_redirect filter: /** * Filters the log out redirect URL. * * @since 4.2.0 * * @param string $redirect_to The redirect destination URL. * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. * @param WP_User $user The WP_User object for the … Read more

wp_logout() changes in WordPress 5.1.1

A lot has changed in 5.1/5.1.1, but the changes I’m seeing in WordPress core wouldn’t cause 302 redirects on their own. 1. wp_logout is pluggable wp_logout is a pluggable function. That means anyone can override this function and cause it to do something different because the function is wrapped in a condition checking for other … Read more

Get wp_logout_url function to work on external (non-WordPress) page

To allow WordPress functions to operate outside of the WordPress environment, you need to let your external pages know about and have access to the WordPress Core and API environment. http://codex.wordpress.org/Integrating_WordPress_with_Your_Website The above link is one such reference which covers this very purpose. Specifically, In order to transform regular PHP pages into ones that utilize … Read more

wp_logout Not Logging Me Out

wp_logout() calls clear_auth_cookie(), which expires all authorization cookies set. It doesn’t change the value of the global $current_user variable. So technically you’re still logged in for the duration of the script. If you’re using wp_logout in your own code, its probably best to exit or wp_redirect immediately afterwards. You can call wp_set_current_user(0) after wp_logout() to … Read more

Clearing cookie on logout and session expiration

Try setting $experation to a negative integer: function myplugin_cookie_expiration( $expiration, $user_id, $remember ) { return $remember ? $expiration : -600; } add_filter( ‘auth_cookie_expiration’, ‘myplugin_cookie_expiration’, 99, 3 ); From the w3schools PHP page on cookies: <?php // set the expiration date to one hour ago setcookie(“user”, “”, time()-3600); ?>