Created
February 16, 2017 15:24
-
-
Save sjaved87/944ac3780026dec6298be2bc3b785ac4 to your computer and use it in GitHub Desktop.
List expired members of Membership 2 in a table with a shortcode. It can be used standalone without Membership 2 plugin (just remove the condition in loop).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function listexpiremembers_func( $atts, $content ) { | |
if ( !defined( 'MS_PLUGIN' ) ) return $content; | |
$args['subscription_status'] = 'expired'; | |
$all_members = MS_Model_Member::get_members( $args ); | |
$total_items = MS_Model_Member::get_members_count( $args ); | |
if( $all_members ){ | |
// Array of stdClass objects. | |
$returner = '<table>' ; | |
$returner .= '<tr>' ; | |
$returner .= '<th>First Name</th>'; | |
$returner .= '<th>Last Name</th>'; | |
$returner .= '<th>Eamil</th>'; | |
$returner .= '<th>Business Phone</th>'; | |
$returner .= '<th>Cell Phone</th>'; | |
$returner .= '<th>Business Name</th>'; | |
$returner .= '</tr>' ; | |
foreach ( $all_members as $user ) { | |
$member = MS_Factory::load( 'MS_Model_Member', $user->ID ); | |
$subscription = $member->get_subscription( 1422 ); | |
$user_id = $user->wp_user->data->ID; | |
$user = $user->wp_user->data; | |
if(function_exists('get_cimyFieldValue')){ | |
$businessname = get_cimyFieldValue($user_id , $feildname = 'businessname'); | |
$workphone = get_cimyFieldValue($user_id , $feildname = 'workphone'); | |
$cellphone = get_cimyFieldValue($user_id , $feildname = 'cellphone'); | |
} | |
$user_name_first = get_user_meta($user_id, 'first_name', true); | |
$user_name_last = get_user_meta($user_id, 'last_name', true); | |
$returner .= '<tr>'; | |
$returner .= '<td>'. esc_html( $user_name_first ) .'</td>'; | |
$returner .= '<td>'. esc_html( $user_name_last ) .'</td>'; | |
$returner .= '<td>'. esc_html( $user->user_email ) .'</td>'; | |
if(function_exists('get_cimyFieldValue')){ | |
$returner .= '<td>'. esc_html( $workphone ) .'</td>'; | |
$returner .= '<td>'. esc_html( $cellphone ) .'</td>'; | |
$returner .= '<td>'. esc_html( $businessname ) .'</td>'; | |
} | |
$returner .= '</tr>'; | |
if ( $member->has_membership() ){} | |
} | |
$returner .= '</table>' ; | |
}else{ | |
$returner .= 'No members found!' ; | |
} | |
return $returner; | |
} | |
add_shortcode( 'list-expire-members', 'listexpiremembers_func' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment