Display on members with field set
-
Hi,
I have a field called Paper Mail which is a check box. I would like to have a page that displays only members that have the check box checked. Is there a way to display only the members that have the checked box rather than all members sorted my the Paper Mail field?
-
Hi,
SELECT*FROM
xx_usermetaWHEREmeta_keyLIKE‘%snail_mail%’ gives the results:snail_mail a:1:{i:0;s:3:”Yes”;}
SELECT*FROM
xx_um_metadataWHEREum_keyLIKE‘%snail_mail%’ gives the results:snail_mail a:1:{i:0;s:3:”Yes”;}
So, it looks like both tables give the same results.
SELECT*FROM
xx_um_metadataWHEREum_keyLIKE‘%snail_mail%’ANDum_valueLIKE‘%Yes%’shows 4 results
SELECT*FROM
xx_usermetaWHEREmeta_keyLIKE‘%snail_mail%’ANDmeta_valueLIKE‘%Yes%’also shows 4 results.
Very good.
UM is copying only fields required for the Directory forms
to theum_metadatatable.What about your sorting field
lot?Not good as the UM directory listing is displaying no users instead of the 4 that is should be showing.
Try to remove these lines for the sorting from the code snippet.
$obj->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = %s )", $sortby ); $obj->sql_order = ' ORDER BY CAST( umm_sort.um_value AS CHAR ) ASC ';How is the setting for these Users about “Hide in Directory”?
-
This reply was modified 10 months ago by
missveronica.
Hi,
I commented out those lines in functions.php but still no users are showing up.
I don’t know where to look to answer your question: “How is the setting for these Users about “Hide in Directory”?” I don’t see a “Hide in Directory” setting in the Member Directory for Paper Mail List or anything like that in the User settings.
Thanks again for your help.
It’s the “Allow users to hide their profiles from directory”
at UM settings -> General -> AccountHi,
I am using UM 2.10.3 and don’t have an “Allow users to hide their profiles from directory” under UM > Settings > General > Account.
Thank you.
This setting is always available in the free default UM 2.10.3 version.
Do you have any other custom code regarding the Directory?Look at “Back-end settings for the Privacy Account Tab” section in this UM guide:
Hi,
I found the setting, I wasn’t seeing it as I have the Privacy Tab disabled for users.
I don’t have any custom code for UM other than what you gave me. I do have 2 of your plugins installed:
- Ultimate Member – Additional Email Recipients – 2.3.0
- Ultimate Member – Admin Email Profile Update – 4.7.2
Thank you
-
This reply was modified 10 months ago by
ljkeashly.
You can try this updated code snippet
add_action( 'um_pre_users_query', 'um_pre_users_query_field_set', 10, 3 ); function um_pre_users_query_field_set( $obj, $directory_data, $sortby ) { global $wpdb; $form_id = 765; $meta_key = 'snail_mail'; $meta_value = 'a:1:{i:0;s:3:"Yes";}'; $sortby = 'lot'; if ( isset( $directory_data['form_id'] ) && $directory_data['form_id'] == $form_id ) { $meta_key = sanitize_key( $meta_key ); $obj->joins = array(); $obj->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_{$meta_key} ON umm_{$meta_key}.user_id = u.ID"; $obj->where_clauses = array(); $obj->where_clauses[] = $wpdb->prepare( "( umm_{$meta_key}.um_key = '{$meta_key}' AND umm_{$meta_key}.um_value = %s )", $meta_value ); $obj->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = %s )", $sortby ); $obj->sql_order = ' ORDER BY CAST( umm_sort.um_value AS CHAR ) ASC '; } }Hi,
Success the list is now showing the 4 users that it should.
Thank you so much for all your help!!!!!
-
This reply was modified 10 months ago by
The topic ‘Display on members with field set’ is closed to new replies.