I already created admin column in WP using this code:
add_filter('manage_pages_columns', 'page_custom_cols', 10);
function page_custom_cols($pages_columns, $post_type) {
$pages_columns['user_group'] = 'User Group';
return $pages_columns;
}
Now I added the function to get the user group id, this field is already in wp_post
table but in a comma separated text just like this: ” 1,7,2 ” and I was able to display it using this function:
add_action('manage_pages_custom_column', 'display_page_custom_cols', 10, 2);
function display_page_custom_cols($col_name, $post_id) {
if ('user_group' == $col_name) {
$pages = get_post($post_id);
echo $pages->group_access;
}
}
And it was showing now. My problem right now is I want to display the User Group Name not the ID
. It was in the table custom_user_group
.
Try this code:
Use the above code and add your approach to retrieve the name using $singleGroupId