1

In the plugin I am developing I am using the following code to build my menu -

add_menu_page('BCRM Plugin Settings', 'BCRM',
    'administrator', __FILE__, 'bcrm_settings_page', BOOGIE__PLUGIN_URL .
    '_inc/img/icon_settings.png');
add_submenu_page( __FILE__, 'BCRM Customer Settings', 'Customer Settings',
    'administrator', 'BCRM', 'bcrm_customer_settings_page');
add_submenu_page( __FILE__, 'BCRM Form Settings', 'Form Settings',
    'administrator', 'BCRM', 'bcrm_form_settings_page');

My functions are built like this -

function bcrm_settings_page() {
    if ( !current_user_can( 'manage_options' ) )  {
        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    }
    require_once( BOOGIE__PLUGIN_DIR . 'views/options.php' );
}

function bcrm_customer_settings_page() {
    if ( !current_user_can( 'manage_options' ) )  {
        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    }
    require_once( BOOGIE__PLUGIN_DIR . 'views/customer_settings.php' );
}

function bcrm_form_settings_page() {
    if ( !current_user_can( 'manage_options' ) )  {
        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    }
    require_once( BOOGIE__PLUGIN_DIR . 'views/form_settings.php' );
}

When ever I view the contents of these menus, they look to be loading my views twice. So if I click on Customer Settings, I get the content of both views loading like this -

Customer Relations Management This is the customers page.

Customer Relations Management This is the forms page.

What am I doing that is causing my two views to load on every page?

1 Answer 1

1

I was using the same page name for both.

You can see in this snippet that I used "BCRM" and I didn't realize it.

add_submenu_page( __FILE__, 'BCRM Customer Settings', 'Customer Settings',
    'administrator', '**BCRM**', 'bcrm_customer_settings_page');
add_submenu_page( __FILE__, 'BCRM Form Settings', 'Form Settings',
    'administrator', '**BCRM**', 'bcrm_form_settings_page');

I changed them to BCRM_customers and BCRM_forms respectively and it is now 100% functional.

This was a silly mistake that came from not carefully reading. If you see duplications, check for duplicate page names.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.