• Resolved tbkpg87

    (@tbkpg87)


    How can I show mobile phone number in filter column in user list in admin part of wordpress?

    • This topic was modified 3 years, 7 months ago by tbkpg87.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @tbkpg87

    Unfortunately, this requires customization on your end.

    You can try adding the following code snippets to your theme/child-theme’s functions.php file or use the Code Snippets plugin to run the code:

    add_filter('manage_users_columns', 'um_060721_column_order');
    function um_060721_column_order($columns) {
        $n_columns = array();
        $before = 'email'; // move before this
        foreach($columns as $key => $value) {
            if ($key==$before){
                $n_columns['birth_date'] = '';
                $n_columns['status'] = '';
            }
            $n_columns[$key] = $value;
        }
        return $n_columns;
    }
    
    function um_070821_custom_define() {
        $custom_meta_fields = array();
        $custom_meta_fields['mobile_number'] = 'Mobile Number';
        return $custom_meta_fields;
    }
    
    function um_070821_columns($defaults) {
        $meta_number = 0;
        $custom_meta_fields = um_070821_custom_define();
        foreach ($custom_meta_fields as $meta_field_name => $meta_disp_name) {
         $meta_number++;
            $defaults[('um_070821-usercolumn-' . $meta_number . '')] = __($meta_disp_name, 'user-column');
        }
        return $defaults;
    }
    function um_070821_custom_columns($value, $column_name, $id) {
        $meta_number = 0;
        $custom_meta_fields = um_070821_custom_define();
        foreach ($custom_meta_fields as $meta_field_name => $meta_disp_name) {
        $meta_number++;
            if( $column_name == ('um_070821-usercolumn-' . $meta_number . '') ) {
            $value = get_user_meta( $id, $meta_field_name, true );
            
            }
        }
        return $value;
    }
    
    add_action('manage_users_custom_column', 'um_070821_custom_columns', 15, 3);
    add_filter('manage_users_columns', 'um_070821_columns', 15, 1);
    Thread Starter tbkpg87

    (@tbkpg87)

    Hello @champsupertramp ,the mobile number search filtering does not work for me in the search engine

    • This reply was modified 3 years, 7 months ago by tbkpg87.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @tbkpg87

    Unfortunately, the custom code above only displays the mobile number in the User table column as per your first topic.

    You will need further customization to make it work with the Search form. Let’s see if others in the forum have done something similar and share their solution here.

    Regards,

    • This reply was modified 3 years, 7 months ago by Champ Camba.
    Thread Starter tbkpg87

    (@tbkpg87)

    Thank you very much for your help

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @tbkpg87

    Thanks for letting us know. I’m marking this as resolved now.

    Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘show the mobile number in the column’ is closed to new replies.