$ms = IB_Educator_Memberships::get_instance(); $membership_meta = $ms->get_membership_meta($post_id); echo $ms->format_price($membership_meta['price'], $membership_meta['duration'], $membership_meta['period']); } } /** * Delete membership data when a user is deleted. * * @param int $user_id */ public static function on_deleted_user($user_id) { global $wpdb; $tables = ib_edu_table_names(); $wpdb->delete($tables['members'], array('user_id' => $user_id), array('%d')); } /** * Order memberships by menu_order of the memberships admin page. * * @param WP_Query $query */ public static function memberships_menu_order($query) { if ($query->is_main_query() && 'ib_edu_membership' == $query->query['post_type']) { $query->set('orderby', 'menu_order'); $query->set('order', 'ASC'); } } } IB_Educator_Memberships_Run::init();
/** * Test if plugin sends membership expiration notifications to students. */ public function testMembershipExpirationNotification() { add_filter('wp_mail', array($this, 'wp_mail_expiration_notification')); $ms = IB_Educator_Memberships::get_instance(); $user = wp_insert_user(array('user_login' => 'expired3', 'user_email' => '*****@*****.**', 'user_pass' => '123456', 'role' => 'student')); $membership = $this->addMembership(array('price' => 100, 'period' => 'months', 'duration' => 1, 'categories' => array($this->categories[0]))); $ms->setup_membership($user, $membership); $in5days = strtotime('+ 5 days', strtotime(date('Y-m-d 23:59:59'))); $ms->update_user_membership($user, array('expiration' => date('Y-m-d H:i:s', $in5days))); $_SERVER['SERVER_NAME'] = 'localhost'; IB_Educator_Memberships_Run::send_expiration_notifications(); }