Searchable meta value in user.php

enter image description here

I have created a new column in the user table list (admin page) and would like the column to be searchable in the search query, How do i add the meta to the search users query ?

/**
 * Create user column (admin panel)
 */
add_filter( 'manage_users_columns', 'new_modify_user_table' );
function new_modify_user_table( $column ) 
{
    $column['kundnummer'] = 'Kundnummer';
    return $column;
}

/**
 * Add content to user column (admin panel)
 */
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
function new_modify_user_table_row( $val, $column_name, $user_id ) 
{
    switch ($column_name) {
        case 'kundnummer' :
            return get_user_meta( $user_id, 'woocommerce_customer_id', true );
            break;
        default:
    }
    return $val;
}

Read more here:: Searchable meta value in user.php

Leave a Reply

Your email address will not be published. Required fields are marked *