I am trying for the first time to build a plugin for WordPress following OOP way.
I am having some problems while trying to create a submenu page using add_users_page() function.

Here is a simple version of my code :

class MyPlugin  {
    public function __construct()
       add_action('admin_menu', array($this, 'create_menu'));
    public static function create_menu()
    add_users_page( 'My Plugin Menu', 'My Plugin Menu (Test)', 'list_users', 'mp_test_page', array($this, 'display_test_page'));
    public static function display_test_page()
    if ( !current_user_can( 'list_users' ) )  {
    wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    echo '<h2>Test page</h2>';
    echo '<p>The Problem : I cannot see that output in the corresponding submenu page</p>';
new MyPlugin();

The problem is that I cannot see the html output in the display_test_page() function… although the submenu page was indeed created in the Users general menu.

Thank you in advance for your help,

Read more here: Creating a menu page in a Object Oriented developed plugin


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: