07-27-2023, 12:08 PM
I have created a special form within my site that allows my users to enter a key. I am using `add_user_meta()` to add the meta data into the database. I want to be able to see this key when I click on users in the admin center.
How would I go about adding to this column?
Below is the meta data info im using
add_user_meta($userId,'code','12345');
We just want to be able to add it to the view on users.php in the table displaying username email and role.
I have used code like this to display the user id but I can not figure out how to display their meta.
add_filter('manage_users_columns', 'pippin_add_user_id_column');
function pippin_add_user_id_column($columns) {
$columns['user_id'] = 'User ID';
return $columns;
}
add_action('manage_users_custom_column', 'pippin_show_user_id_column_content', 10, 3);
function pippin_show_user_id_column_content($value, $column_name, $user_id) {
$user = get_userdata( $user_id );
if ( 'user_id' == $column_name )
return $user_id;
return $value;
}
How would I go about adding to this column?
Below is the meta data info im using
add_user_meta($userId,'code','12345');
We just want to be able to add it to the view on users.php in the table displaying username email and role.
I have used code like this to display the user id but I can not figure out how to display their meta.
add_filter('manage_users_columns', 'pippin_add_user_id_column');
function pippin_add_user_id_column($columns) {
$columns['user_id'] = 'User ID';
return $columns;
}
add_action('manage_users_custom_column', 'pippin_show_user_id_column_content', 10, 3);
function pippin_show_user_id_column_content($value, $column_name, $user_id) {
$user = get_userdata( $user_id );
if ( 'user_id' == $column_name )
return $user_id;
return $value;
}