Membership 2 Pro in a multi site environment with redirect issues

I'm using Membership 2 pro on our wordpressua.uark.edu multi site. My issue is on this site:
grapes.uark.edu

I've created a page called Membership Pro (/membership-pro) to test with. It's in the main nav menu under "Members Only". Upon clicking on the page the user is brought to a login screen (perfect), but after logging in they aren't redirected to "grapes.uark.edu/membership-pro" but rather to "wordpressua.uark.edu/membership-pro". That is our main site in the multi site installation. I'm sure this is a quick fix, but I couldn't find it anywhere.

Thanks,
Nathan

  • Kasia Swiderska

    Hello Nathan,

    I tried to replicate this issue with redirect but I could not. When Membership is only activated on subsite in network and user registers through the Membership and then uses login form on protected page there is no redirection to main site.
    Would you mind allowing support access so we can have a closer look at this?
    To enable support access you can follow this guide here:
    http://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    kind regards,
    Kasia

  • Kasia Swiderska

    Hello Nathan,

    I'm sorry for delay here but I'm not able to check your site settings not test it - remote login is disabled in network so I'm asked to login when I try access to subsite and registration on subsite is also disabled so I cannot register and login.
    Is it ok for me to Allow new registrations? Could you please send in the following via our secure contact form https://premium.wpmudev.org/contact/ :

    - Mark to my attention, the subject line should contain only: ATTN: Kasia Swiderska
    - Do not include anything else in the subject line, doing so may delay our response due to how email filtering works.
    - Link back to this thread
    - Include WordPress subsite admin access details (username & password)
    - Include any relevant URLs for your site

    IMPORTANT: Please make sure you select "I have a different question" for your topic, so it doesn't go back to the forums - this and the subject line ensure that it gets assigned to me.

    kind regards,
    Kasia

  • Kasia Swiderska

    Hello Nathan,

    I'm sorry for delay on my end - I'm checking your settings and everything looks fine, however I cannot check whole network settings.
    Did Membership was ever Network activated in your network? Can you check if you have this define in wp-config.php

    define( 'MS_PROTECT_NETWORK', true );

    Do I understand correctly that your network is installed on subdomain wordpressua but subsites are also subdomains for uark.edu and not for wordpressua.uark.edu (that would be default behavior for Multisite installation in subdomain). May I ask if you did additional configuration to get your Network work like that? Any htaccess rules?

    kind regards,
    Kasia

  • Ash

    Hello Nathan

    I could not replicate the issue but I can assume something. Would you please try the following code?

    add_filter( 'ms_model_plugin_protected_content_page', function( $url ) {
        $no_access_page_url = MS_Model_Pages::get_page_url(
            MS_Model_Pages::MS_PAGE_PROTECTED_CONTENT,
            false
        );
    
        $current_page_url = home_url() . '/' . $_SERVER['REQUEST_URI'];
    
        $no_access_page_url = esc_url_raw(
            add_query_arg(
                array( 'redirect_to' => urlencode( $current_page_url ) ),
                $no_access_page_url
            )
        );
    
        return $no_access_page_url;
    }, 99, 1 );

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.