I'm using the following custom plugin to count the number of members in the MemberPress database:
function display_member_count( $atts ) {
global $wpdb;
$sql = "SELECT COUNT(`meta_key`) as count FROM `wp_usermeta` WHERE `meta_key` = 'mepr-address-state' && `meta_value` = '" . $atts[0] . "';";
$myrows = $wpdb->get_results($sql);
$member_count = $myrows[0]->count;
return $member_count;
}
add_shortcode( 'member-count', 'display_member_count' );
I would then use the shortcode [member-count nsw]
to display the number of members in NSW.
Do I need to sanitize $atts
? If so, how please?
Help appreciated.