Advertisement
verygoodplugins

Untitled

Jul 9th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. function add_custom_meta_field( $meta_fields ) {
  2.  
  3.     $membership_levels = get_posts(
  4.         array(
  5.             'post_type'  => 'llms_membership',
  6.             'nopaging'   => true,
  7.             'fields'     => 'ids'
  8.         )
  9.     );
  10.  
  11.     foreach ( $membership_levels as $id ) {
  12.  
  13.         $meta_fields[ 'llms_enrolled_' . $id ] = array( 'label' => 'Enrolled in ' . get_the_title( $id ), 'type' => 'date', 'group' => 'lifterlms' );
  14.  
  15.     }
  16.  
  17.     return $meta_fields;
  18.  
  19. }
  20.  
  21. add_filter( 'wpf_meta_fields', 'add_custom_meta_field', 20 );
  22.  
  23. function added_to_membership( $user_id, $membership_id ) {
  24.  
  25.     if ( function_exists( 'wp_fusion' ) ) {
  26.  
  27.         wp_fusion()->user->push_user_meta( $user_id, array( 'llms_enrolled_' . $membership_id => time() ) );
  28.  
  29.     }
  30.  
  31. }
  32.  
  33. add_action( 'llms_user_added_to_membership_level', 'added_to_membership', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement