[aff_permanent_count] shortcode

If you are using Affiliates Pro / Enterprise with Affiliates Permanent by @itthinx, and you need to count how many customers are linked to an affiliate, this shortcode can help you:

add_shortcode( 'aff_permanent_count', 'aff_permanent_count' );
function aff_permanent_count( $atts ) {
global $wpdb;
$affiilate_id = Affiliates_Affiliate_WordPress::get_user_affiliate_id();
$meta_key = Affiliates_Permanent::REFERRER;
$meta_value = $affiilate_id;
$user_meta_query = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->usermeta WHERE meta_key=%s AND meta_value=%s", $meta_key, $meta_value ) );
return number_format_i18n($user_meta_query);
}