• So basically the plugin works great except one thing. When I click on the Log out link provided by the Meta widget on the sidebar the page goes to the standard WordPress log in screen.

    I don’t know if I have to do something other than installing the plugin and changing settings to my liking. It would be nice if on Log out it would take you to the home page of the site or to the alst page you were viewing.

    Any ideas why this is happening? thanks in advance.

Viewing 1 replies (of 1 total)
  • That is the default behavior. If you want to override it, you need to pass in a redirect url to the wp_loginout() function. Since you are using the Meta widget, the easier thing to do is add the following code to your functions.php theme file:

    function my_loginout($link) {
    	if (strpos($link, 'redirect') === false) {
    		$parts = explode(" ", $link);
    		foreach ($parts as &$part) {
    			if (strpos($part, 'href') === 0) {
    				$redirect = sprintf('%sredirect_to=%s">',
    					strpos($part, '?') === false ? '?' : '&',
    					$_SERVER['REQUEST_URI']
    				);
    				$part = str_replace('">', $redirect, $part);
    			}
    		}
    		$link = implode(" ", $parts);
    	}
    
    	return $link;
    }
    add_filter('loginout', 'my_loginout');

    In short, that adds the necessary redirect_to parameter to the Log In/Out links. If you only want it for the Log Out link, you can use the following:

    function my_loginout($link) {
    	if (strpos($link, 'redirect') === false && strpos($link, 'action=logout') !== false) {
    		$parts = explode(" ", $link);
    		foreach ($parts as &$part) {
    			if (strpos($part, 'href') === 0) {
    				$redirect = sprintf('%sredirect_to=%s">',
    					strpos($part, '?') === false ? '?' : '&',
    					$_SERVER['REQUEST_URI']
    				);
    				$part = str_replace('">', $redirect, $part);
    			}
    		}
    		$link = implode(" ", $parts);
    	}
    
    	return $link;
    }
    add_filter('loginout', 'my_loginout');
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: SimpleModal Login] On log out goes back to standard WordPress log in’ is closed to new replies.