• Hi,

    Great plugin but I’m facing 2 issues on my site.

    1. Logout link not working.
    2. When anyone came from Facebook to access the content, it will redirect to login.php instead of that particular content.

    By default if anyone logged in on my site, it will redirect to homepage first – (WP User Manager Plugin setting).
    Also, I’m using customized login page (‘/login/’ – WP User Manager plugin) for my site. So I had disabled the default WordPress login page. Below is the code:

    /**
    * Disable default WordPress login
    **/
    function custom_wp_redirect_admin_locations() {
    global $wp_rewrite;
    if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) )
    return;

    $admins = array(
    home_url( ‘wp-admin’, ‘relative’ ),
    home_url( ‘dashboard’, ‘relative’ ),
    home_url( ‘admin’, ‘relative’ ),
    site_url( ‘dashboard’, ‘relative’ ),
    site_url( ‘admin’, ‘relative’ ),
    );
    if ( in_array( untrailingslashit( $_SERVER[‘REQUEST_URI’] ), $admins ) ) {
    wp_redirect( admin_url() );
    exit;
    }

    $logins = array(
    home_url( ‘wp-login.php’, ‘relative’ )
    );
    if ( in_array( untrailingslashit( $_SERVER[‘REQUEST_URI’] ), $logins ) ) {
    wp_redirect( site_url( ‘wp-login.php’, ‘login’ ) );
    exit;
    }
    }

    function remove_default_login_redirect() {
    remove_action(‘template_redirect’, ‘wp_redirect_admin_locations’, 1000);
    add_action( ‘template_redirect’, ‘custom_wp_redirect_admin_locations’, 1000 );
    }

    add_action(‘init’,’remove_default_login_redirect’);

    /**
    * Change default WordPress login URL
    **/
    function login_redirect() {
    global $pagenow;
    if ($pagenow == ‘wp-login.php’ && empty($_POST)) {
    wp_redirect(‘/user-login/’);
    exit();
    }
    }
    add_action(‘init’,’login_redirect’);

    /**
    * Redirect user once Logged In
    **/
    function redirect_login_page() {
    $login_page = home_url( ‘/login/’ );
    $page_viewed = basename($_SERVER[‘REQUEST_URI’]);
    if ($page_viewed == “wp-login.php” && $_SERVER[‘REQUEST_METHOD’] == ‘GET’) {
    wp_redirect($login_page);
    exit;
    }
    }
    add_action(‘init’,’redirect_login_page’);

    /**
    * Whitelist specified URLs/pages
    **/
    function my_forcelogin_whitelist( $whitelist ) {
    $whitelist[] = site_url( ‘/login/’ );
    $whitelist[] = site_url( ‘/sign-up/’ );
    $whitelist[] = site_url( ‘/register/’ );
    $whitelist[] = site_url( ‘/product/premium-membership/’ );
    $whitelist[] = site_url( ‘/product/annual-premium-membership/’ );
    $whitelist[] = site_url( ‘/cart/’ );
    $whitelist[] = site_url( ‘/checkout/’ );
    $whitelist[] = site_url( ‘/home/’ );
    $whitelist[] = site_url( ‘/password-reset/’ );

    return $whitelist;
    }
    add_filter(‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’, 10, 1);

    Kindly check my code and suggest the necessary solution.
    Looking for the quick reply.
    Thanks in advance!!
    Regards,

  • The topic ‘Logout Not Working’ is closed to new replies.