Advertisement
verygoodplugins

Untitled

Jun 14th, 2023
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1.     /**
  2.      * Check before Sync a bp member to ld.
  3.      *
  4.      * @since BuddyBoss 1.5.0
  5.      */
  6.     public function syncBeforeBpMember( $group_object ) {
  7.  
  8.         // If no ld group sync.
  9.         if ( empty( $this->ldGroupId ) ) {
  10.             return $group_object;
  11.         }
  12.  
  13.         $post_label_prefix = 'group';
  14.         $meta              = learndash_get_setting( $this->ldGroupId );
  15.         $post_price_type   = ( isset( $meta[ $post_label_prefix . '_price_type' ] ) ) ? $meta[ $post_label_prefix . '_price_type' ] : '';
  16.         $post_price        = ( isset( $meta[ $post_label_prefix . '_price' ] ) ) ? $meta[ $post_label_prefix . '_price' ] : '';
  17.  
  18.         // format the Course price to be proper XXX.YY no leading dollar signs or other values.
  19.         if ( ( 'paynow' === $post_price_type ) || ( 'subscribe' === $post_price_type ) ) {
  20.             if ( '' !== $post_price ) {
  21.                 $post_price = preg_replace( '/[^0-9.]/', '', $post_price );
  22.                 $post_price = number_format( floatval( $post_price ), 2, '.', '' );
  23.             }
  24.         }
  25.  
  26.         if ( ! empty( $post_price ) && ! learndash_is_user_in_group( bp_loggedin_user_id(), $this->ldGroupId ) ) {
  27.             $group_object->group_id = null;
  28.         }
  29.  
  30.         return $group_object;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement