admin管理员组文章数量:1332881
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?
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?
Share Improve this question edited Jun 29, 2020 at 20:43 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Jun 29, 2020 at 12:54 spamisspamis 113 bronze badges 01 Answer
Reset to default 1Use 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 );
本文标签: How do I create a column in Users list and display user data from custom registration field
版权声明:本文标题:How do I create a column in Users list and display user data from custom registration field 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742308353a2450369.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论