1

Our registration form has a custom field for Hospital Name. In SQL wp_usermeta the meta_key is user_registration_hospital. I have tested a number of snippets in the functions.php file to add a "Hospital" column to the Users admin table, all of which create the Hospital column in the Users list. This is one of the snippets that adds the Hospital column:

function add_user_columns($column) {
   $column['hospital'] = 'Hospital';
   return $column;
}
add_filter( 'manage_users_columns', 'add_user_columns' );

What code do I need to add to the functions.php file to have the Hospital data from wp_usermeta populate the Hospital column?

0
1

Use the following code to add new column and show data properly.

function add_user_columns_hospital( $column ) {
    $column['hospital'] = 'Hospital';
    return $column;
}
add_filter( 'manage_users_columns', 'add_user_columns_hospital' );

function modify_user_table_row_hospital( $val, $column_name, $user_id ) {
    switch ($column_name) {
        case 'hospital' :
            return get_the_author_meta( 'user_registration_hospital', $user_id );
        default:
    }
    return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.