Membership 2 Pro API access error: Call to undefined method MS_Model_Member::get_member

I’m having troubles accessing the Membership 2 Pro API. I have a custom plugin calling the API. (I’ve tried it both from the plugin folder, as well as the muplugin folder, and neither works.)

The following code from here works:

$member = MS_Model_Member::get_current_member();

foreach ( $member->subscriptions as $subscription ) {
$membership = $subscription->get_membership();

$membership_id[] = $membership->id;

but, when I change it to try to call get_member ( $id ), I get the following error: Call to undefined method MS_Model_Member::get_member

$member = MS_Model_Member::get_member( $user_id );

Any ideas what I’m doing wrong? Thanks in advance.

  • Sohag Ronjon Dey
    • Support

    Hi CB,

    Thanks for your query and I hope that you are having a beautiful day! :slight_smile:

    As the classes can not be called directly unless within the plugin or within the plugin’s template files. You need to call it like this

    $member = MS_Factory::load( ‘MS_Model_Member’, $user_id );

    Hope this helps.



Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.