Logout after registraiton

Hi there,
a) I would need users to be logged out once they complete registration. Currently they have full access to the site once they complete registration. What's the best way to have them logged out automatically after registering?

b) We would need a waiver to be presented to every member once they login and then have them accept it. What's the best way to do this?

Would be great if you could help out... thanks!

  • Jude

    Hi Maarten,

    Hope all is well with you and you are keeping fine !

    a) I would need users to be logged out once they complete registration. Currently they have full access to the site once they complete registration. What's the best way to have them logged out automatically after registering?

    Just to clarify, why exactly do you want the users to be logged out ? I'm trying to understand the exact nature of the modification needed, because the plugin needs a user to have selected a membership and be logged in before being sent to the payment gateway. On return, their payment status can be seen on the MyAccounts page. Logging them out mid way will stop this. Thanks for clarifying.

    b) We would need a waiver to be presented to every member once they login and then have them accept it. What's the best way to do this?

    https://premium.wpmudev.org/project/terms-of-service/

    Will something like this work ? Also, is this a one time waiver or do they need to accept each time they login ?

    Thank you for being a WPMU DEV member and have a fantastic day !

    Cheers
    Jude

  • Maarten

    Hi Jude,
    thank you so much for your fast reply!

    a) Here is what I would like to happen: The user goes to
    http://iwc-lausanne.org/membership-application/
    then has to click on the SIGNUP button to proceed to the registration form.
    Once they click on register my account it then takes them to a page where they see how they can pay their dues.

    The way I had it set up before was as a paid membership but there were too many steps in the signup process I felt. Once they clicked on SIGNUP they had to fill out everything, click on REGISTER MY ACCOUNT and then they were brought to a page where they had to click SIGNUP again confirming to accept paying their dues. Then they were taken to the thank you page which included the details on how they can pay.

    Now I set it up as a free membership because this way they don't have to click signup again after leaving the registration form.

    In both cases we only want to grant access to members after we manually screened them.
    We don't allow them to choose a pasword so they cannot login until we provide them with a password.

    BUT

    now they are signed in once they finish the signup process because like you said they need to be logged in in order to be passed to the payment gateway. Just that in our case we only provide them with payment details so they can make a bank transfer.

    I hope it wasn't too confusing.

    regarding b) ... I already added a required profile field with a link to the registration form so that works for new members. For exisitng members however I don't know yet how I could present them with the TOS and have a record somewhere of who accepted the terms and who didnt.

    Thank you so much!

  • Ash

    Hi there

    Please try the following code for automatic logout after registration:

    add_filter( 'ms_model_pages_redirect_to', function( $url, $page_type, $args ) {
            if( $page_type == MS_Model_Pages::MS_PAGE_REG_COMPLETE && isset( $args['ms_relationship_id'] ) )
            {
                    return str_replace( '&' . 'amp;', '&', wp_logout_url( home_url() ) );
            }
            return $url;
    }, 10, 3 );

    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.

    About the TOS issue, I think you can create a custom TOS page where people will login and agree. Then you can send an email to everyone to accept the TOS. This has to be custom though but still the easiest to achieve.

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

    Cheers
    Ash

  • Luís

    Hi Maarten ,

    Hope you're doing well today!

    Working here alongside with my teammate Jude and Ashok.

    I have discussed this with Ashok and actually this will not work with a paid membership, because it will break the signup process.

    So, as an workaround, we need to use a free membership and this code to automatically logout the user after registration:

    add_filter( 'ms_model_pages_redirect_to', function( $url, $page_type, $args ) {
            if( $page_type == MS_Model_Pages::MS_PAGE_REG_COMPLETE && isset( $args['ms_relationship_id'] ) )
            {
                    return str_replace( '&', '&', wp_logout_url( home_url() ) );
            }
            return $url;
    }, 10, 3 );

    If I understood well, also, you want a paid membership too, where you will sent the details to a bank transfer, right?

    Another workaround to this proccess, it's creating another Paid Membership (using the Manual Payment Gateway) and set it as private, to don't be listed on your site and avoid users to register on it.

    Then, in the free membership created previously, set an expiration (i.e 1 day) and then, the user will be moved to the paid membership.

    So, the entire proccess will be:

    1) Users register to a free membership and will be logout after the registration;

    2) After 1 day, the access will expire and they will be moved the paid membership;

    3) Will check the invoice in the account page to pay with the "Manual Payment" option.

    I hope this information has been helpful. If I can help you in this or other questions, please let me know!

    Cheers, Luís

  • Maarten

    Took me a while to get back to you ...
    Thanks so much Luis, this was of great help!

    Another question: Would there be a way to have the user logged out once they finish the signup process and click on the PAY button (manual payment)?

    I haven't yes implemented the solution you sugested above and am wondering if there was a way around it without a free membership.

    They are logged in automatically once they fill out the registration form and click on the button to send it. Then they are taken to the payment gateway page which in my case is just another page with some information. At this stage they are logged in. Once they click on the button on this page the signup process is complete and they are taken to the HOW TO PAY PAGe (in our case).

    So maybe on that last step - from the payment gateway to the "thank you/how to pay page" there could be an automatic logout?

    Thanks so much!

  • Ash

    Hello Maarten

    Please try the following code:

    add_action( 'ms_gateway_free_process_purchase', function() {
        wp_logout();
    } );

    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.

    Please note that, the above code will work only the membership is free.

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

    Cheers
    Ash