• Resolved ljkeashly

    (@ljkeashly)


    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?

Viewing 11 replies - 16 through 26 (of 26 total)
  • Thread Starter ljkeashly

    (@ljkeashly)

    Hi,

    SELECT*FROMxx_usermetaWHEREmeta_keyLIKE‘%snail_mail%’ gives the results:

    snail_mail a:1:{i:0;s:3:”Yes”;}

    SELECT*FROMxx_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*FROMxx_um_metadataWHEREum_keyLIKE‘%snail_mail%’ANDum_valueLIKE‘%Yes%’

    shows 4 results

    SELECT*FROMxx_usermetaWHEREmeta_keyLIKE‘%snail_mail%’ANDmeta_valueLIKE‘%Yes%’

    also shows 4 results.

    @ljkeashly

    Very good.

    UM is copying only fields required for the Directory forms
    to the um_metadata table.

    What about your sorting field lot ?

    Thread Starter ljkeashly

    (@ljkeashly)

    Not good as the UM directory listing is displaying no users instead of the 4 that is should be showing.

    missveronica

    (@missveronicatv)

    @ljkeashly

    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”?

    Thread Starter ljkeashly

    (@ljkeashly)

    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.

    missveronica

    (@missveronicatv)

    @ljkeashly

    It’s the “Allow users to hide their profiles from directory”
    at UM settings -> General -> Account

    Thread Starter ljkeashly

    (@ljkeashly)

    Hi,

    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.

    missveronica

    (@missveronicatv)

    @ljkeashly

    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:

    https://docs.ultimatemember.com/article/1911-account

    Thread Starter ljkeashly

    (@ljkeashly)

    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.
    missveronica

    (@missveronicatv)

    @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 ';
        }
    }
    Thread Starter ljkeashly

    (@ljkeashly)

    Hi,

    Success the list is now showing the 4 users that it should.

    Thank you so much for all your help!!!!!

Viewing 11 replies - 16 through 26 (of 26 total)

The topic ‘Display on members with field set’ is closed to new replies.