Tagged: display featured users
Hi GP,
That’s strange.Here is the loop used for showing the featured members(in list view)
https://github.com/buddydev/bp-featured-members/blob/master/templates/members-loop-list.phpThe args come from
https://github.com/buddydev/bp-featured-members/blob/master/core/bp-featured-members-shortcode.php#L11I don’t see anything in the plugin.
The only other way is user loop getting modified externally(BuddyPress, WordPress user query).
I have no idea what is causing it. Try adding query monitor and check for the queries.
Regards
BrajeshPut in Query Monitor and this was the only obvious item on the page where I’m running the shortcode
SELECT user_id
FROM wp_usermeta
WHERE meta_key = ‘_is_featured’
AND meta_value = ‘1’And this was in the Caller column for that query
the_content()
wp-includes/post-template.php:240
apply_filters(‘the_content’)
wp-includes/plugin.php:203
do_shortcode()
wp-includes/shortcodes.php:197
preg_replace_callback()
wp-includes/shortcodes.php:319
do_shortcode_tag()
wp-includes/shortcodes.php:319
bp_featured_members_shortcode()
wp-content/plugins/bp-featured-members/core/bp-featured-members-shortcode.php:61
bp_fm_load_members_list()
wp-content/plugins/bp-featured-members/core/bp-featured-members-functions.php:68
bp_has_members()
wp-content/plugins/buddypress/bp-members/bp-members-template.php:415
BP_Core_Members_Template->__construct()
wp-content/plugins/buddypress/bp-members/classes/class-bp-core-members-template.php:144
bp_core_get_users()
wp-content/plugins/buddypress/bp-members/bp-members-functions.php:142
BP_User_Query->__construct()
wp-content/plugins/buddypress/bp-core/classes/class-bp-user-query.php:191
BP_User_Query->prepare_user_ids_query()
wp-content/plugins/buddypress/bp-core/classes/class-bp-user-query.php:455I never have figured out why the plugin’s shortcode isn’t working.
However, because I like your interface for Setting and Removing featured status for members, I wrote my own shortcode.
I’m putting it in here in case it’s helpful to anyone else:
function display_featured_members() { $return_string = '<ul class="featured-members">'; $args = array( 'meta_key' => '_is_featured', 'orderby' => 'display_name', 'order' => 'ASC' ); // The Query $user_query = new WP_User_Query( $args ); // User Loop if ( ! empty( $user_query->get_results() ) ) { foreach ( $user_query->get_results() as $user ) { $key = '_is_featured'; $featured_state = get_user_meta( $user->ID, $key, true ); if ( $featured_state == '1' ) { $return_string .= '<li>' . $user->display_name . '</li>'; } } } else { $return_string .= 'No users found.'; } $return_string .= '<ul>'; return $return_string; } function bmm_shortcodes_init() { add_shortcode('bmm-featured-members', 'display_featured_members'); } add_action('init', 'bmm_shortcodes_init');
Hi George,
Thank you for sharing.If the above code is working that definitely means some code is filtering bp_after_has_members_parse_args or bp user query.
I still appreciate the code sharing.
Regards
Brajesh
You must be logged in to reply to this topic.