SHARE
TWEET

Untitled

a guest Nov 13th, 2018 23 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $status = get_user_meta( $id , 'wpcf-status' , true );
  4.  
  5. if( $status !== 'active' ) {
  6. return;
  7. }
  8.  
  9. $membership = get_user_meta( $id , 'wpcf-membership-id' , true ); //returns the ID for the membership to assign
  10. $start_date = get_user_meta( $id , 'wpcf-start-date' , true ); //returns the start date for the membership in format 'Ymd'
  11. $end_date = get_user_meta( $id , 'wpcf-expire-date' , true ); //returns the expire date to apply in format 'Ymd'
  12.  
  13. $api = ms_api();
  14.  
  15. $member = $api->get_member( $id );
  16.  
  17. $subscription = $member->add_membership( $membership );
  18.  
  19. if( $start_date !== '' ) {
  20. $subscription->set_start_date( $start_date );
  21. }
  22.  
  23. if( $end_date !== '' ) {
  24. $subscription->set_expire_date( $end_date );
  25. }
  26. $subscription->status = MS_Model_Relationship::STATUS_ACTIVE;
  27. $subscription->save();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top