How to add Loginout to Sub-menu
How to add Loginout to Sub-menu
How to add Loginout to Sub-menu
logout error “something went wrong”
Problem with is_user_logged_in() function in some pages
Use wp_logout_url() https://developer.wordpress.org/reference/functions/wp_logout_url/ <a href=”<?php echo wp_logout_url(); ?>”>Logout</a>
The cause of your error is that the filter receives and is expected to return a WP_Error object, null is not an error object. We can confirm this via the docs, and enforce it via type hinting: function my_logout_message( \WP_Error $error ) : \WP_Error { Additionally, if your code had worked, all errors would be … Read more
How to logout the current user without notices and warnings?
Using wp_logout_url() is your best choice. You will need to create a <a> tag and in the href attribute output wp_logout_url() <a href=”<?= wp_logout_url(“https://wordpress.stackexchange.com/”); ?>” title=”Logout”>Logout</a> I passed / as an argument because after the user will click the link he will be redirected back to the homepage, you can change it to what ever … Read more
Change auth_cookie_expiration for specific roles and specific login times
Based on the suggestion of @JacobPeattie to use a cookie, I’ve constructed following working solution for this question: /* LOGIN / LOGOUT */ /* — */ /* AUTOLOGIN */ if( isset($_GET[‘username’]) ) { $user = get_user_by(‘login’, $_GET[‘username’]); // Redirect URL // if ( !is_wp_error( $user ) ) { if ( in_array( ‘customer’, (array) $user->roles ) … Read more
logout users with specific role after close browser tab