API for Membership Plugin

Does Membership Pro have an API. I have a client that has their own CRM and they what to directly control member access to the WordPress site vie their CRM. Is there an interface that I can use to allow this? I would need to be able to create new users, add/drop subscription levels etc...

  • Barry
    • DEV MAN’s Mascot

    Hi, we have a number of huge hooks and filters in the plugin and classes that can be used to control the plugin / create users etc.

    Creating users is done via standard WP functions (as the plugin uses standard WP users) - subscriptions can be added using the subscriptions class - I always direct people to the membershipincludes/includes/functions.php file initially to see if the functions in there are of any help.

    I'm adding more hooks all the time, so am always willing to add specific ones that are needed.

  • Barry
    • DEV MAN’s Mascot

    Here is how to creata a WordPress user in code -

    There is an example in there that returns a $user_id - you then use this to add a subscription (assuming you know the subscription_id and it's stored in a variable called $sub_id) - note, I'm assuming you want to add a subscription here and not a level (they are two different things, so not 100% sure what you mean by subscription level).

    $member = new M_Membership( $user_id );
    $member->add_subscription( $sub_id );
  • dgaltieri
    • Flash Drive

    Yes this has helped... I need some direction more than anything... I need to expose an interface within my WP site so that an external website has the ability to create new users and then associate a subscription level to that new user... There would also be the need for this external website to manage these users, for example, change their password, or disable access... Is this something that can be done? I just need to determine where to start.


  • Tom Eagles
    • Syntax Hero

    @dgaltieri thats something i have never tried and i dont even know if it would be possible.
    You would need your wp database to be writeable from an external site. It could in theory be done if the application (external website) had the permissions set on the mysql database. But it's a potentially huge security risk if not done properly. I have seen many of the cheaper shared hosting services have an external mysql database that people can setup the database for wordpress to use on install.



  • Barry
    • DEV MAN’s Mascot

    Yes, you are looking at implementing an external api really there, which could potentially open a huge security risk with your site, as Tom wrote above.

    You'll need to think it through very carefully and are basically looking at implementing an api key system, with maybe ip restrictions and a method of revoking access for certain keys/ ips and probably an operation logging system so you can check for abuse of the api and rollback changes, etc.

  • aecnu
    • WP Unicorn

    Greetings dgaltieri,

    We have not heard back from you as to the status of this issue.

    If you are still having an issue please let us know so that we may try to get you fixed up as soon as possible by choosing to check mark this ticket as unresolved below and posting any new errors or symptoms you are noticing.

    This action will also bring your ticket up front back in plain view again within the ticket system.

    Thank you for being a WPMU DEV Community Member!

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.