• Resolved LizONBC

    (@lizonbc)


    I just downloaded WP-Members today. I really like the plugin so far, but I can’t get the logout to redirect to the homepage. I followed the code below given by you, Chad, in your instructions. The login portion worked, but the logout did not. Any ideas what could be the problem?

    add_filter( ‘wpmem_login_redirect’, ‘my_login_redirect’, 10, 2 );

    function my_login_redirect( $redirect_to, $user_id ) {
    // return the url that the login should redirect to
    return ‘http://www.ataitec.net/’;
    }

    add_filter( ‘wpmem_logout_redirect’, ‘my_logout_redirect’ );

    function my_logout_redirect()
    {
    // return the url that the logout should redirect to
    return ‘http://www.ataitec.net’;
    }

    https://wordpress.org/plugins/wp-members/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    The plugin’s logout links already direct the user to the homepage. So if the logout is directing somewhere else, then that link isn’t generated by the plugin; in which case the wpmem_logout_redirect filter has no control over it.

    You can use logout_url to filter the link, the second argument is a redirect url.

    There is also a setting the Advanced Options extension available to support subscribers that allows you to set this along with a number of overrides of WP defaults.

    Thread Starter LizONBC

    (@lizonbc)

    I tried logout_url to filter the link and it did not work. I used this exactly:

    add_filter( ‘logout_url’, ‘my_logout_page’, 10, 2 );
    function my_logout_page( $logout_url, $redirect ) {
    return home_url( ‘/my-logout-page/?redirect_to=’ . $redirect );
    }

    Should I have added a specific link in there somewhere? Please understand I am a novice here and don’t really understand CSS.

    Plugin Author Chad Butler

    (@cbutlerjr)

    Should I have added a specific link in there somewhere? Please understand I am a novice here and don’t really understand CSS.

    Considering that this is not CSS but PHP, I’m wondering where you put this filter? It should go in your theme’s functions.php file.

    Thread Starter LizONBC

    (@lizonbc)

    I put it in the Child Theme’s functions.php file.

    Plugin Author Chad Butler

    (@cbutlerjr)

    Sorry… I should have looked at specifically what your return url was in the filter as you applied it.

    Try it this way:

    add_filter( 'logout_url', 'my_logout_page', 10, 2 );
    function my_logout_page( $logout_url, $redirect ) {
    	return add_query_arg( 'a', 'logout', home_url() );
    }
    Thread Starter LizONBC

    (@lizonbc)

    That did the trick. Thanks.

    Liz

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP-Members – Logout Redirect to Homepage did not work’ is closed to new replies.