How to restrict browser back button after logout?
Just Put this code in your user history details page if(is_user_logged_in()){ // your user history details code }else{ wp_redirect(“Your login Page url”); }
Just Put this code in your user history details page if(is_user_logged_in()){ // your user history details code }else{ wp_redirect(“Your login Page url”); }
You could create a custom Page template which contains only the logout code, no call to header.php etc. When you load the /member-logout/ page you’re probably calling the default page.php template which is loading header.php etc. If instead you apply your custom Page template it will just perform the logout action and can then redirect, … Read more
wp_logout_url($uri) having two redirect values
You might have to trigger wp_logout() yourself in that case: if ( $pagenow == “wp-login.php” && $_SERVER[‘REQUEST_METHOD’] == ‘GET’ ) { if ( (isset($_GET[‘action’])) && ($_GET[‘action’] == ‘logout’) ) { wp_logout(); } wp_redirect($new_login_page_url); exit; } That said, it sounds like a real pain to reinvent wp-login.php and handle the different form actions etc… a plugin … Read more
You can work with is_user_logged_in() function to create a if / else statement in your menu. Here a quick code. <?php if ( is_user_logged_in() ) { ?> <li class=”menu-item”><a href=”https://website.com/my-account/orders/”><i class=”fa fa-handshake-o”></i>My Orders</a></li> <li class=”menu-item”><a href=”https://website.com/my-account/customer-logout/”><i class=”avatar”></i>Log out</a></li> <?php } else { ?> <li class=”menu-item”><a class=”porto-link-login” href=”https://website.com/my-account/”><i class=”fa fa-user”></i>Log In</a></li> <?php } ?> You could … Read more
Yes, the code on your login.php?action=logout page can call wp_logout() to log out. You probably also want to hook the logout_url filter to generate your new logout URL, else menu bars and the admin site will still try to use wp_login.php.
You could use WP Cron to fire wp_logout() and make it more reliable by following instructions here https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/ Below is code for a plugin that would log everyone out, every day at midnight. Note if you wanted to schedule a one-time-only, single event, use wp_schedule_single_event instead of wp_schedule_event https://codex.wordpress.org/Function_Reference/wp_schedule_single_event // hook function myplugin_cron_hook() to the … Read more
logout error “something went wrong”
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
You shouldn’t be echoing anything directly from your functions.php. Doing so will prevent redirects. Remove line 226 and you should be good to go. You might want to replace that whole remove_admin_bar with something better coded (or a plugin even).