Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Bojan Radonic – WPMU DEV Support

    (@wpmudev-support4)

    Hey there cvak,

    Hope you’re well today ??

    I’m not sure I understand what exactly are you looking to do here. Membership levels are not connected or dependent on user roles in WordPress.

    You can assign any level to user with any role (aside from site admin who has access to all protected content by default).

    With that being said can you please add more details on what you’re trying to achieve so I can better understand your issue.

    Looking forward for your response ??

    Best regards,
    Bojan

    Thread Starter cvak

    (@cvak)

    Hello Bojan!

    Thanks for your answer.
    I solved that problem but there has been a new problem.
    When my script add (after first login) new membership to user, it change ID to something new.

    Example: User has membership id=”2792″, after login user get membership id=”2319″.

    script code:

    MS_Plugin::$api->get_member($user_id)->drop_membership(2792);
    MS_Plugin::$api->get_member($user_id)->add_membership(2319);

    In Membership 2 plugin is user membership id=”2319″, which is OK, but when I debug it write that user membership id is “2348”( I dont have any membership with that role)

    What I do wrong?

    p.s.
    At first when I create new member script add successful membership id!
    MS_Plugin::$api->get_member($user_id)->add_membership(2792 );

    Plugin Author Bojan Radonic – WPMU DEV Support

    (@wpmudev-support4)

    Hey again cvak,

    Can you please add more details about your debugging process so we can better understand the issue.

    Best regards,
    Bojan

    Thread Starter cvak

    (@cvak)

    Hey Bojan,

    I have users without memberships, and I want to add him through php code.
    I use the following php code for adding membership.

    MS_Plugin::$api->get_member($user_id)->add_membership($membership_id);

    This code worked just fine for me, but after that I want to add another(change) membership for user( I use upper code), but when I want get user memberships, I get some different membership ID.

    What I do wrong?

    P.S. If I add membership to user(who dont have any) through wp-admin(no php code) and then work with php codes(add_membership, drop_membership,…) it WORKS!

    Hey there ??

    Great to see you’re using the M2 API! I’ll try to help you out with that issue, but I cannot yet tell exactly what’s going wrong.

    My first suspicion:
    When you add a membership to a user the user will get a new Subscription. Maybe at some point you confuse the membership-ID with the subscription-ID…
    You could try to hardcode the membership-ID for a test using the exact ID displayed in the M2 Memberships page.

    Can you post the whole code (or link to the file on github/etc) that you use to add and check the membership to an user?
    What I need to see: When do you add the membership to the user, which ID you add, the debug code that shows the wrong ID (i.e. the code I can use on my site to reproduce the issue)

    Though basically your code/how you use it looks correct.

    Thanks, Philipp

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Membership user role merge HELP’ is closed to new replies.