I have created a new page in admin. I need to show all the users in this page(like Users admin page).

The reason for this is because i want to show certain custom user roles only on this page.

I tried using WP_List_Table but no luck in figuring out on how to implement.

This is the function i have, i need to put the code inside here.

add_action( 'admin_menu', 'cypolicy_users_admin_menu' );

function cypolicy_users_admin_page_contents() 
echo "<h1>" . esc_html_e( 'CyPolicy Users', 'cypolicy-users-plugin-textdomain' ) . "</h1>";


Can someone kindly guide me.

  • 1
    have you considered instead modifying the admin menu to lead to the dedicated role listing pages that already exist? e.g. /wp-admin/users.php?role=editor wouldn't adding that as a menu in the sidebar under users also solve the problem this is trying to resolve? WP_List_Table and brand new pages aren't necessary
    – Tom J Nowell
    Dec 13, 2021 at 14:39
  • @TomJNowell yes i did, but the client want a seperate page. Please see my menu structure here. This is how he wants snipboard.io/5Bg9w4.jpg Dec 13, 2021 at 16:17
  • I don't see why that isn't possible, just add it as a menu instead of a sub-menu, nothing prevents you from adding new menu pages in the admin menu, whether they lead to custom pages, or URLs that already exist, or even google.com ( developer.wordpress.org/reference/functions/add_menu_page )
    – Tom J Nowell
    Dec 14, 2021 at 0:43
  • e.g. something similar to this will add a top level nav menu item called Google visible to editors: add_menu_page( 'Google', 'Google', 'edit_posts', 'https://google.com', '', 'dashicons-admin-home', 1);, nothing stops you doing this with the role filters, and it's 1000x easier than what you're trying to do (and unlike your proposed solution it's compatible with plugins etc)
    – Tom J Nowell
    Dec 14, 2021 at 0:48
  • @TomJNowell the point here is that i need a seperate page. I dont need menu now. I have already created a blank page. I want to show the list of user there. Dec 14, 2021 at 6:43


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.