Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Assign membership on registration in membership 2 pro
<?php
add_action( 'user_register', 'assign_membership_on_register', 10, 1 );
function assign_membership_on_register( $user_id ) {
$membership_id = 1343;
$member = MS_Factory::load( 'MS_Model_Member', $user_id );
$subscription = $member->add_membership( $membership_id );
if ( $member->has_membership() ) {
$member->is_member = true;
} else {
$member->is_member = false;
}
$member->save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.