[Membership 2 Pro] Membership workflow flawed - free/default membership

Ok, so I set up a Free membership type so that registered members could get access to our full free article archive (as opposed to just the latest posts/Editor's Picks - that's me :slight_smile: ). The trouble is, there is already the "default" membership type for those that haven't joined another membership yet.

With the default membership, if you click on the register link, you have to register first, then sign up. This is confusing for a start. I appreciate it is because first you are registering for a WordPress account, then signing up as a member, but the average user doesn't know that. It means there may be users who have Default membership and those that are Free members, with little or no difference between them. This was causing more confusion (for me!) when hiding premium content. So I deleted Free, leaving the Default membership to get on with it.

Without it, however, when you click on a sign up link (ms shortcode), it takes you to the list of memberships, which now only displays the paid membership. Now, you can edit the standard membership page, which I did, to add a registration link. But that is only available to logged-in users, a bit pointless!

It would be better to change the Register link so it goes to the Membership list. That would avoid the confusion - is there a way of changing the Register link in the widget?

I don't know how you guys at WPMU Dev do it, but the whole membership experience here is great (better than the plugin)...from login to profile views...when can we have some of that??!!

I'll probably have to go back to creating a Free membership and try and ensure the default membership has the same protection rules, but the register link in the widget is still confusing. Any advice?

Cheers!

  • Adam Czajczyk
    • Support Gorilla

    Hello Arthur

    I hope you're doing fine today :slight_smile:

    The "default" membership is kind of "special" as it covers only those users that are registered but did not sign up for any existing membership. It's mostly useful if you already have existing users on site before setting up a Membership 2 Pro plugin or if you have disabled Membership 2 Pro registration because e.g. you're using some custom registration form (e.g. from Gravity Forms).

    I'd say that in most cases, it's best to stick to the "standard" type memberships that you create.

    However, there's indeed a difference in the "flow" between widget and the registration pages.

    With a widget, users is always taken directly to the form (with or without "default" membership) and with standard registration pages (or a shortcode, like you mentioned), it's always the membership list first and then the form. It's the same regardless whether the "default" membership exists or not.

    I admit I'm not quite sure why is that so, so I"ll put it under developers' consideration.

    As for now, you could use additional piece of code to actually alter the "register" link of a widget so it would take users directly to a membership list (that would add some "unification" to the workflow).

    <?php
    add_action( 'wp_footer', 'change_ms_widget_register_link' );
    function change_ms_widget_register_link() {
    
        $register_url = wp_registration_url();
        ?>
        <script type="text/javascript">
        jQuery( function( $ ){
            var href = $( '.widget_ms_widget_login a' ).attr( 'href' );
            $( '.widget_ms_widget_login a' ).attr( 'href', '<?php echo $register_url ?>' );
        } );
        </script>
        <?php
    }

    To apply it to your site:

    - create an empty file with a .php extension (e.g. "ms-widget-register-link.php");
    - copy&paste code from above into that file using some "clean text" editor (such as e.g. Notepad++, Sublime or similar)
    - upload the file to the "/wp-content/mu-plugins" folder of your site's WP install (via FTP or cPanel); if there's no "mu-plugins" folder inside "wp-content" folder, just create an empty one first.

    I hope that helps!

    Best regards,
    Adam

  • Arthur
    • The Incredible Code Injector

    Thanks Adam,

    I was writing "perfect", as that's what I was after, but unfortunately this code also changes the logout link so when you try to log out it also takes you to the membership list page (without logging you out)!

    Presumably we need to specify more variables...a separate link for register and logout (not sure how it works at the moment - or how, if normally the two functions happen in the same place and so your code changes both).

    Cheers,
    Arthur

  • Predrag Dubajic
    • Support

    Hi Arthur,

    Can you try using this code instead and see if that does the trick for you:

    <?php
    add_action( 'wp_footer', 'change_ms_widget_register_link' );
    function change_ms_widget_register_link() {
    
        $register_url = wp_registration_url();
        ?>
        <script type="text/javascript">
        jQuery( function( $ ){
            var href = $( '.widget_ms_widget_login > a' ).attr( 'href' );
            $( '.widget_ms_widget_login > a' ).attr( 'href', '<?php echo $register_url ?>' );
        } );
        </script>
        <?php
    }

    Best regards,
    Predrag

  • Arthur
    • The Incredible Code Injector

    Hi again,
    I can't remember why now, but I had moved the php file to disable the function and now when I put it back, it's not working - the register link in the login widget goes to the WP registration/account creation page instead of the membership list.

    I have enabled support access on the test site (imustardtest.co.uk), if you could please have a look. FTP details in the access window to avoid the system sending them back by insecure email.

    Thanks!
    Arthur

  • Predrag Dubajic
    • Support

    Hi Arthur,

    Is this code being applied on your applied-********-governance.com site?
    I'm afraid that support access is not working for me there as it redirects me to 404 page, as well as any attempt to access WP admin pages.

    I also don't see any M2 widgets in the sidebar on that site, am I looking at the correct site? :slight_smile:

    Best regards,
    Predrag

  • Predrag Dubajic
    • Support

    Hi Arthur,

    Oh, you did mentioned that above, I completely missed, sorry about that :slight_frown:

    I can access your site now and see the issue but I'm afraid that FTP login is not working for me and it keeps saying "Could not connect to server", do I need to edit my hosts file in order to access your files?

    Best regards,
    Predrag

  • Arthur
    • The Incredible Code Injector

    Hi Predrag,

    Oops, sorry, yes, I have just changed the primary domain on the hosting account ahead of transferring the domain.

    I've added the main SiteGround login to the support access notes so you can access the account itself and so cPanel.

    Cheers,
    Arthur

  • Adam Czajczyk
    • Support Gorilla

    Hello Arthur

    Thanks for providing access credentials.

    I checked the site and made a small change in the code: removed one line that wasn't necessary there (I missed it before, it was a "leftover" from testing) and I made the selector "stronger"

    .widget_ms_widget_login .ms-membership-form-wrapper > a

    instead of just

    .widget_ms_widget_login > a

    Additionally, I made forced entire code to be called a bit later but that's a "cosmetic" thing, I think :slight_smile:

    It looks like it's working now. I admit I'm not sure what else could have changed since it was working previously but those changes seem to be helping.

    Best regards,
    Adam

  • Arthur
    • The Incredible Code Injector

    Hi Adam,

    Thanks, that does indeed work. Bit of a mystery, as you say, why it stopped working, but hopefully it is more robust anyway now. Now to apply it to the development site so I can launch the new site! (I am still trying to figure out the login redirect with Kasia, but I reckon that doesn't matter - if I wait any longer I'll need shears for my beard!! :joy: )

    Cheers!
    Arthur

  • Arthur
    • The Incredible Code Injector

    Any ideas why on my dev server this wouldn't be working? I copied the code from the test site, refreshed the dev site page (which worked with the test site), cleared the browser cache - and even purged the CDN cache. Still showing as /register/?step=register instead of just /register.

    I can't imagine it's just because it's not publicly accessible (except through changing local hosts)...

    I'd really like to go live, but with people signing up regularly to the mailing list on the old site, which will now be done probably through registration (synched with the list), I'd like to get it sorted before.

    Any ideas most welcome. If necessary, I'll put it live anyway so we can all see this version...

    Thanks!
    Arthur

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.