【发布时间】:2021-12-23 22:49:33
【问题描述】:
在 WordPress 用户的个人资料中,我有自定义用户元设置 _yith_wcact_user_ban
自定义字段是一个真/假复选框。
我已将必要的代码添加到 functions.php 以添加此自定义用户元以显示在 users.php 的列中。
但是,如何返回值以在列中显示Verfied 或Unauthorised?
_yith_wcact_user_ban = true = 未经授权
_yith_wcact_user_ban = false = 已验证
function add_custom_column_name($columns) {
$columns['columns_array_name'] = 'Verification';
return $columns;
}
function show_custom_column_values($value, $column_name, $user_id) {
if ( 'columns_array_name' == $column_name )
return get_user_meta( $user_id, '_yith_wcact_user_ban', true );
return('Unauthorised');
}
add_filter('manage_users_columns', 'add_custom_column_name');
add_action('manage_users_custom_column', 'show_custom_column_values', 10, 3);
任何帮助将不胜感激。
谢谢。
【问题讨论】:
标签: php wordpress advanced-custom-fields