Membership 2 Pro - partial registration woes

So...

The issue I have is really about stopping sneaky sneaky people from semi-completing the membership registration process to see semi protected content.

I have sent up the paywithalike plugin to show a 'like' message if people aren't members of my site (or more correctly to not show the PWAL message if they are 'subscribers').

The PWAL message I use suggests people become members to avoid seeing the 'like-wall' and (yada yada) support the site.

People then register for an account to start the membership process but then skip the lovely paying bit. However they now have site account so can happily skip my 'like-wall' and I end up with no likes and no money.

Ideally then, people only become 'subscribers' if they've completed paying for a modestly priced membership (we use mailchimp for our newsletter so don't need subscribers per se).

There might be a better way of achieving what we're after or even some tweak we missed any help much appreciated.

A

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    This will be tricky one but with help of one code snippet it can be done. First - in Pay with a Like you need to change what user role can see content behind the PWAL - it cannot be default role because this one is added when people register.

    User Level Where Authorization Starts – This will only become available if Authorized Users See Content is set to yes.

    So next step is to add to your site this code snippet https://gist.github.com/bappi-d-great/794bd6a18eecb59f8f27 where you put ID of membership and role that can see content.
    This way only when users will join membership and their role will be changed they will be able to see content.

    You can add code to your themes functions.php file or use it as MU Plugin http://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    Awesome, will give it a try in a bit.

    One question though. If I set new membership user to 'contributor' and then make PWAL messages not appear for contributors, won't this mean that paid up members (who will become 'listed' as contributors via Membership 2 Pro) can then log into the admin part of WP and start uploading all sorts of things (though happily not publishing) as contributors?

    thanks again,
    A

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    No, Contributor doesn't have that capabilities - please see here https://codex.wordpress.org/Roles_and_Capabilities#Contributor - they can create posts and deletes them (only their own) but higher roles can only publish them. They cannot upload also.
    Other solution is to create custom role with capabilities as subscriber or remove contributor capabilities - but you would need to use additional plugin for that like this one https://wordpress.org/plugins/members/

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    Thanks Kasia,
    It's as I thought. Ideally the WP Member wouldn't be able to log into WP Admin at all because it's seems like a security hole to some extent.

    I've installed the plugins/members you suggested... however I hit a bit of a snag. I first tried to create a new role with only read capabilities however WP gave this new role a level 0 rating (like subscriber) and thus it wouldn't work with the solution you've provided.

    I then thought I'd be clever and clone the contributor role (level 1), and deny some of the capabilities (edit & delete)... however once I did that the cloned role became relegated to level 0 again... thus defeating the purpose (since we want MemPro2 to create level_1 for PWAL to work).

    I'll ask the plugin author if there's some way to create a 'level_1' role that (cough) doesn't have any permissions that of level (i.e. edit/delete).

    For the record the plugins/member work well at creating roles and they appear in PWAL as level_0 so it seems the Plugins are communicating to some extent.

  • Ananda
    • Site Builder, Child of Zeus

    Hi there,
    The issue was that the new roles don't have an assigned membership level.
    The same author who created the /members plugin also created this.
    http://themehybrid.com/plugins/members-role-levels ($10)

    Which allows you to set levels for roles.
    Seems like this would work and certainly when I amended the role the PYAL read that my new role was a level 1 role... and therefore would let members see content with the PYAL prompt.

    Then, I added the PHP to the function.php file in the appearance/editor after changing all the existing role titles to 'Tmem' (the new role I created for members.

    Sadly, I think I stumbled at this step as now the site won't load and I receive this message.
    "hp
    Warning: Cannot modify header information - headers already sent by (output started at /home/lamelco/public_html/wp-content/themes/mh-magazine/functions.php:222) in /home/lamelco/public_html/wp-includes/pluggable.php on line 1167"
    I had added the Php you sent from github at the bottom of the file.

    Any ideas? on how I can fix this/what I've done wrong?

  • Rupok
    • Support Ninja

    Hi Ananda, hope you had a wonderful day.

    There may be unnecessary <?php tags or there is empty space on Line 222 in your functions.php file here: /home/lamelco/public_html/wp-content/themes/mh-magazine/functions.php

    I could try fixing that if I had your FTP details. Can you send me message with FTP access credentials through our secure contact form here: https://premium.wpmudev.org/contact/

    Subject: "Attn: Rupok"
    - FTP Username
    - FTP Password
    - FTP Host
    - Link back to this thread for reference
    - Any other relevant URLs

    Select "I have a different question" for your topic. This and the subject line ensure that it gets assigned to me.

    This StackOverflow Answer describes in full details why "Headers already sent" error can occur. Can you please follow the suggestions over there to resolve this issue?

    If it's still there after following that thread, please let us know. We will be glad to help further.

    Have a nice day. Cheers!
    Rupok

  • Ananda
    • Site Builder, Child of Zeus

    Hi Kasia,
    Happily it looks like the site is up and running again however now it is saying that 'membership registration is not currently allowed' when I try and sign up.
    I've created a free membership to test the process btw.
    Could you look into the issue?
    BW
    Kailas

  • Rupok
    • Support Ninja

    Hi Kailas, hope you had a wonderful day.

    By any chance, is your registration disabled from settings? Go to "Dashboard > Settings > General" settings and check "Anyone can register" option. Please check the attached screenshot for reference.

    I believe it will solve your issue. If not, 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/

    I'm looking forward to hear from you and resolve this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • Ananda
    • Site Builder, Child of Zeus

    Hey Rupok,
    Well I feel silly now. Checked that box and the site now allows people to sign up!
    However when I checked the new (test) user i just created it was still listed as having the role 'subscriber' rather than the new role 'tmem' as per the php we put in functions.
    So, we're a good step closer but still not cigar?
    Can you check the ftp code you've added to see if it still works?
    K

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    If you look again in that code you will see numbers like 1343 - I'm sorry I didn't mentioned that before - but those are memberships IDs. So it wont work if you left them like that. They have to be your memberships ID. You can check your memberships IDs on the Memberships list -> Shortcodes -> Show.
    For each of your membership you have to have that code:

    case 1343:
    			$user->set_role( 'editor' );
    			break;

    where numbers are your membership ID.
    Then it will work when user will register and join membership.

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    Almost,

    Looks like it's working in that members become 'tmem' once they register.

    However the problem is that when they register on the site they're role 'tmem' and not when they've completed their membership.

    So we're back at square one in that people only have to register to see content rather than register, pay and become members.

    Ideally, when people register for the site (prior to the payment cycle) they are role 'subscribers' and then once they've paid they become role 'tmem'

    Thanks so much for your help you guys are excellent!

    A

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    That snippet code only changes role of user when they join membership - so it is possible that another plugin changes role to custom one before that. Can you check in plugins if nowhere your custom role is set up as default? In General Settings and also in plugin where you created custom role? Default role has to be subscriber.
    I tried to check your site but there was popup asking for password and username and non was working from credentials you send me in email.

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    Hi there Kasia,
    I've checked at subscriber is the default role and as far as I can see none of the other plugins are changing that default.
    I created a test user for the free membership and that had the created role rather than subscriber and then I created another user but did pay and again that new user was given the created role rather than subscriber (payment not complete)
    The U/P (trebuchet/trebuchet) is correct for the pop up (which appears twice)
    Can you try having a look again?
    Best,
    K

  • Nithin
    • Support Wizard

    Hi Ananda,

    Hope you are doing good today. :slight_smile:

    It seems like support access is not enabled, could you please enable support access, so that we could give a closer look. You can grant access from WPMU DEV > Support > Support Access > Grant Access, or check this manual: http://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Please let us know once you enable access, so that we could get this sorted. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    OK. I know what is going on. That code works also on pending memberships - but there is solution to that.
    1) Add default membership. Grab its id.
    2) Add another piece of that code

    case 1343:
    			$user->set_role( 'subscriber' );
    			break;

    change numbers to default membership ID.
    3) make sure that multiple memberships add-on is disabled (well, I checked that one and its disabled)

    Default membership if for register user that didn't join any membership yet - so when they register they will get default one until they join the paid one (until they will pay).

    Let me know if this works for you - I tested that solution recently on my website and got positive results.

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    Success, the solution is working on the dev site!
    However when I try and implement the same code (changing the membership numbers) on the live site. It crashes the site.

    Reinstating the old functions.php brings the site back so no great issue. But I wonder what might be the problem with the functions.php since the configuration is much the same between the dev and live site.

    Any ideas?

    When I was setting up the live site with the same plugins etc I somehow lost appearance>editor which means I've had to use ftp instead to update the function.php file in the theme. Which while not critical is certainly annoying. Wonder if you've ran into this issue before?

    Whew.

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    I'm glad to hear this is working on the dev site!

    However when I try and implement the same code (changing the membership numbers) on the live site. It crashes the site.

    Can you paste your whole functions.php file with code you are trying to add to pastebin.com so I could take a look on what might cause that error?

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    So, did a few changes here and there (adding "?>" to end of the php) and it seems to work on the live site!

    Tried a test membership... and before payment the test user was 'subscriber' after payment the user isn't allocated a role. However after searching for the user their profile shows that they have 'additional capabilities' = member (created role).
    Functionally the change work as before payment the user still gets the likewall and after payment they don't. Which is a success. (We/You did it!)

    I do wonder why the user isn't listed under the users>roles summation "treb mem"?
    It's occurred to me that when I updated the bit of code you sent I set the created role as 'treb mem' rather than 'treb_mem' would the 'space' make a difference? (i.e. 'Role name' rather than 'role')
    Changing the code and trying this new users are added within 'treb mem' role group with their role listed as 'subscriber' sadly they seem to be view all content without paying so have rolled it back.
    Ah well, any ideas?

    Many many thanks!

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    It looks like the role name is important - it should be "slug" for roles name. So if your role name is 'treb mem' then the slug would be treb_mem (I remember that on your dev site role name was different, it was one word name). Other than that your code looks fine.
    Check with change of the role name and let me know.

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    Have updated the slugs etc and seems to be working okay however the site has crashed a few times since.

    I'm wondering if the changes we made might have caused the problem? Your thoughts?

    Checked the logs and am getting these sorts of issues:
    "160915 10:52:56 [ERROR] Cannot find or open table trebuchet/wp_cptch_whitelist from
    the internal data dictionary of InnoDB though the .frm file for the
    table exists. Maybe you have deleted and recreated InnoDB data
    files but have forgotten to delete the corresponding .frm files
    of InnoDB tables, or you have moved .frm files to another database?
    or, the table contains indexes that this version of the engine
    doesn't support."

    with these sorts of errors:
    trebuchet.wp_comments_fbseo
    Error : Table 'trebuchet.wp_comments_fbseo' doesn't exist
    status : Operation failed
    trebuchet.wp_cptch_images
    Error : Table 'trebuchet.wp_cptch_images' doesn't exist
    status : Operation failed
    trebuchet.wp_cptch_packages
    Error : Table 'trebuchet.wp_cptch_packages' doesn't exist
    status : Operation failed
    trebuchet.wp_cptch_whitelist
    Error : Table 'trebuchet.wp_cptch_whitelist' doesn't exist
    status : Operation failed
    trebuchet.wp_eab_booking_meta
    Error : Table 'trebuchet.wp_eab_booking_meta' doesn't exist
    status : Operation failed
    trebuchet.wp_eab_bookings
    Error : Table 'trebuchet.wp_eab_bookings' doesn't exist
    status : Operation failed
    trebuchet.wp_enewsletter_members
    Error : Table 'trebuchet.wp_enewsletter_members' doesn't exist
    status : Operation failed
    trebuchet.wp_enewsletter_meta
    Error : Table 'trebuchet.wp_enewsletter_meta' doesn't exist
    status : Operation failed
    Error : Table 'trebuchet.wp_m_communications' doesn't exist
    status : Operation failed
    trebuchet.wp_m_coupons
    Error : Table 'trebuchet.wp_m_coupons' doesn't exist
    status : Operation failed
    trebuchet.wp_m_levelmeta
    Error : Table 'trebuchet.wp_m_levelmeta' doesn't exist
    status : Operation failed
    trebuchet.wp_m_member_payments
    Error : Table 'trebuchet.wp_m_member_payments' doesn't exist
    status : Operation failed
    trebuchet.wp_m_membership_levels
    Error : Table 'trebuchet.wp_m_membership_levels' doesn't exist
    status : Operation failed
    trebuchet.wp_m_membership_news
    Error : Table 'trebuchet.wp_m_membership_news' doesn't exist
    status : Operation failed
    trebuchet.wp_m_membership_relationships
    Error : Table 'trebuchet.wp_m_membership_relationships' doesn't exist
    status : Operation failed
    trebuchet.wp_m_membership_rules
    Error : Table 'trebuchet.wp_m_membership_rules' doesn't exist
    status : Operation failed
    trebuchet.wp_m_ping_history
    Error : Table 'trebuchet.wp_m_ping_history' doesn't exist
    status : Operation failed
    trebuchet.wp_m_pings
    Error : Table 'trebuchet.wp_m_pings' doesn't exist
    status : Operation failed
    trebuchet.wp_m_subscription_transaction
    Error : Table 'trebuchet.wp_m_subscription_transaction' doesn't exist
    status : Operation failed
    trebuchet.wp_m_subscriptionmeta
    Error : Table 'trebuchet.wp_m_subscriptionmeta' doesn't exist
    status : Operation failed
    trebuchet.wp_m_subscriptions
    Error : Table 'trebuchet.wp_m_subscriptions' doesn't exist
    status : Operation failed
    trebuchet.wp_m_subscriptions_levels
    Error : Table 'trebuchet.wp_m_subscriptions_levels' doesn't exist
    status : Operation failed
    trebuchet.wp_m_urlgroups
    Error : Table 'trebuchet.wp_m_urlgroups' doesn't exist
    status : Operation failed
    trebuchet.wp_options OK
    trebuchet.wp_popover_ip_cache
    Error : Table 'trebuchet.wp_popover_ip_cache' doesn't exist
    status : Operation failed
    Error : Table 'trebuchet.wp_termmeta' doesn't exist
    status : Operation failed

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    Those errors are related to problem with database - it looks like tables are missing and this one code snippet is not operating on whole tables (it does not create or removes databases).
    This is something you should contact your hosting provider and ask if everything is ok with your database (show them those error messages).

    let me know how it will go.

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    Hi there,
    Have a reasonably urgent issue now. Which seems a bit related.
    Once paid members (who are part of the new group we set up) try to login they are reaching a 404 page where normally they'd go to the account page.

    http://www.trebuchet-magazine.com/account/login

    This doesn't happen with user's who have only registered with the site itself.

    Any help greatly appreciated.

    Ps. the database issue seems to have been cleared up with the latest theme upgrade.

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,
    Check if you don't use login redirect add-on and what url is inserted there. Because it looks like there is wrong url there.
    If login form comes from widget it has also option to redirect after login

    If it comes from shortcodes - also check it

    [ms-membership-login redirect_login=&quot;http://customurl.com/&quot;]

    If in any of those there is redirect setup - that needs to be full path, not only /login/ or something similar.

    if you don't find anything like that, please enable support access.

    kind regards,
    Kasia

  • Ananda
    • Site Builder, Child of Zeus

    Hi there is just checked and I don't use a redirect add-on at the moment.

    Adding the redirect add-on I can see that the user goes to trebuchet-magazine.xom/account/ on login? Is that bad?

    I'll enable service access in any case and if you can have a look that would be great.

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    Did you recently added AdRotate Professional plugin? Could you disable it for while for testing login?
    I realize that there is problem with login because page is redirecting instead of checking with Ajax if login is correct. And then I saw jQuery error in browser console that comes from AdRotate.
    When one script breaks on page there is big chance its also breaking other scripts. And Membership login form is using JS to work.

    Also - it is possible that problem with AdRotate is created by minification plugin - so you can also disable this one first and see if this will help.
    Let me know how it went.

    kind regards,
    Kasia

  • Kasia Swiderska
    • Support nomad

    Hello Ananda,

    I found issue and I was able to replicate this on my site. This is Pay with like problem. It throws error

    ReferenceError: pwal_data is not defined

    It adds some of it's scripts to Membership 2 Pro login form and makes it unusable. I can't figure why its doing so and I cannot make it working on my site, so I'm marking this as bug and letting developer know about issue.
    I will let him know that its urgent matter.

    kind regards,
    Kasia

  • Nithin
    • Support Wizard

    Hi Ananda,

    Hope you are doing good today. :slight_smile:

    I'm afraid, there isn't any exact ETA on when a patch to this bug will be issued. I'm pinging the developer, about the status of this issue. Will keep you updated, once we have a fix regarding this. We truly appreciate your patience. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Rupok
    • Support Ninja

    Hi Ananda,

    I do apologize for the delay. Can you please login to your server with any FTP application like FileZilla and go to "/wp-content/plugins/pay-with-a-like/js/" directory? There you should see a file named "pay-with-a-like.js". Please open that file and add the following code:

    if (typeof pwal_data === "undefined") {
    		   return;
    }

    Right BEFORE the following code:

    if ( pwal_data.debug == "true" ) {
    			console.log('pwal_data[%o]', pwal_data);
    }

    Then save the file.

    I believe this will resolve the issue. Please let us know if it doesn't. We will be very glad to investigate further.

    I'm looking forward to hearing from you and resolving this issue as soon as possible.

    Regards,
    Rupok

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.