Getting user_ids from database error
-
Hello,
I am trying to get user_ids of users that have field a certain filed in their profiles to show only them in a custom members loop.
global $wpdb;
$db_query = "SELECT user_id FROM wp_bp_xprofile_fields WHERE field_id = 2 AND value !empty";
$match_ids = $wpdb->get_var($db_query);
$get_these_members = '&per_page=20&type=newest&include=' .$match_ids;
if ( bp_has_members($get_these_members) ) :
I think there’s a syntax error, and !empty is not the correct way for this, I tried a lot of options non of the works.
To test it, I tried this line:
$db_query = "SELECT user_id FROM wp_bp_xprofile_fields WHERE field_id = 2 AND value = 45";
where 45 is the value of the filed for one of the members, but it still doesn’t show any member.I found that I need to implode the user_ids list from the forum, but it doesn’t help neither.
It returns ‘Sorry, no members were found.’
when I enable wp_debug appears this error
‘WordPress database error: [Unknown column ‘user_id’ in ‘field list’]’Could you please help me?
Thanks,
Leo
- The topic ‘Getting user_ids from database error’ is closed to new replies.