Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2.  
  3. <?php
  4.  
  5. $status = get_user_meta( $id , 'wpcf-status' , true );
  6.  
  7. if( $status !== 'active' ) {
  8. return;
  9. }
  10.  
  11. $membership = get_user_meta( $id , 'wpcf-membership-id' , true ); //returns the ID for the membership to assign
  12. $start_date = get_user_meta( $id , 'wpcf-start-date' , true ); //returns the start date for the membership in format 'Ymd'
  13. $end_date = get_user_meta( $id , 'wpcf-expire-date' , true ); //returns the expire date to apply in format 'Ymd'
  14.  
  15. $api = ms_api();
  16.  
  17. $member = $api->get_member( $id );
  18.  
  19. $subscription = $member->add_membership( $membership );
  20.  
  21. if( $start_date !== '' ) {
  22. $subscription->set_start_date( $start_date );
  23. }
  24.  
  25. if( $end_date !== '' ) {
  26. $subscription->set_expire_date( $end_date );
  27. }
  28. $subscription->status = MS_Model_Relationship::STATUS_ACTIVE;
  29. $subscription->save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement