Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $status = get_user_meta( $id , 'wpcf-status' , true );
- if( $status !== 'active' ) {
- return;
- }
- $membership = get_user_meta( $id , 'wpcf-membership-id' , true ); //returns the ID for the membership to assign
- $start_date = get_user_meta( $id , 'wpcf-start-date' , true ); //returns the start date for the membership in format 'Ymd'
- $end_date = get_user_meta( $id , 'wpcf-expire-date' , true ); //returns the expire date to apply in format 'Ymd'
- $api = ms_api();
- $member = $api->get_member( $id );
- $subscription = $member->add_membership( $membership );
- if( $start_date !== '' ) {
- $subscription->set_start_date( $start_date );
- }
- if( $end_date !== '' ) {
- $subscription->set_expire_date( $end_date );
- }
- $subscription->status = MS_Model_Relationship::STATUS_ACTIVE;
- $subscription->save();
Add Comment
Please, Sign In to add comment