Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ffp_sync_expiration_date( $membership, $args ) {
- $user_membership = wc_memberships_get_user_membership( $args['user_membership_id'] );
- ////////// FFP Adding code to add Expiration date & Status as custom user field in AC for each membership
- $ffp_plan_id = $user_membership->plan_id;
- ////////// Vet membership Start
- if ( $ffp_plan_id == 917 ) {
- $ffp_status = $user_membership->get_status();
- $ffp_update_data = array(
- 'membership_status_vet' => $ffp_status,
- );
- if( ! empty( $user_membership->get_end_date() ) ) {
- $ffp_update_data['membership_expiration_vet'] = $user_membership->get_end_date();
- }
- wp_fusion()->user->push_user_meta( $args['user_id'], $ffp_update_data );
- }
- ////////// Vet membership End
- ///
- ////////// Student membership Start
- if ( $ffp_plan_id == 2264775 ) {
- $ffp_status = $user_membership->get_status();
- $ffp_update_data = array(
- 'membership_status_student' => $ffp_status,
- );
- if( ! empty( $user_membership->get_end_date() ) ) {
- $ffp_update_data['membership_expiration_student'] = $user_membership->get_end_date();
- }
- wp_fusion()->user->push_user_meta( $args['user_id'], $ffp_update_data );
- }
- ////////// Student membership End
- ///
- ////////// Trainer membership Start
- if ( $ffp_plan_id == 188504 ) {
- $ffp_status = $user_membership->get_status();
- $ffp_update_data = array(
- 'membership_status_trainer' => $ffp_status,
- );
- if( ! empty( $user_membership->get_end_date() ) ) {
- $ffp_update_data['membership_expiration_trainer'] = $user_membership->get_end_date();
- }
- wp_fusion()->user->push_user_meta( $args['user_id'], $ffp_update_data );
- }
- ////////// Trainer membership End
- ///
- ////////// Groomer membership Start
- if ( $ffp_plan_id == 1012216 ) {
- $ffp_status = $user_membership->get_status();
- $ffp_update_data = array(
- 'membership_status_groomer' => $ffp_status,
- );
- if( ! empty( $user_membership->get_end_date() ) ) {
- $ffp_update_data['membership_expiration_groomer'] = $user_membership->get_end_date();
- }
- wp_fusion()->user->push_user_meta( $args['user_id'], $ffp_update_data );
- }
- ////////// Groomer membership End
- ///
- ////////// CP Registered membership Start
- if ( $ffp_plan_id == 2549808 ) {
- $ffp_status = $user_membership->get_status();
- $ffp_update_data = array(
- 'membership_status_cpregistered' => $ffp_status,
- );
- if( ! empty( $user_membership->get_end_date() ) ) {
- $ffp_update_data['membership_expiration_cpregistered'] = $user_membership->get_end_date();
- }
- wp_fusion()->user->push_user_meta( $args['user_id'], $ffp_update_data );
- }
- ////////// CP Registered membership End
- ///
- ////////// CP Leader membership Start
- if ( $ffp_plan_id == 326174 ) {
- $ffp_status = $user_membership->get_status();
- $ffp_update_data = array(
- 'membership_status_cpleader' => $ffp_status,
- );
- if( ! empty( $user_membership->get_end_date() ) ) {
- $ffp_update_data['membership_expiration_cpleader'] = $user_membership->get_end_date();
- }
- wp_fusion()->user->push_user_meta( $args['user_id'], $ffp_update_data );
- }
- ////////// CP Leader membership End
- ///
- ////////// Certified Practice membership Start
- if ( $ffp_plan_id == 326153 ) {
- $ffp_status = $user_membership->get_status();
- $ffp_update_data = array(
- 'membership_status_cpmember' => $ffp_status,
- );
- if( ! empty( $user_membership->get_end_date() ) ) {
- $ffp_update_data['membership_expiration_cpmember'] = $user_membership->get_end_date();
- }
- wp_fusion()->user->push_user_meta( $args['user_id'], $ffp_update_data );
- }
- ////////// Certified Practice membership End
- //////// FFP End Added code to add Expiration date & Status as custom user field in AC for each membership
- if( ! empty( $user_membership->get_end_date() ) ) {
- wp_fusion()->user->push_user_meta( $args['user_id'], array( 'membership_expiration' => $user_membership->get_end_date() ) );
- }
- }
- add_action( 'wc_memberships_grant_membership_access_from_purchase', 'ffp_sync_expiration_date', 20, 2 );
Add Comment
Please, Sign In to add comment