This is the main plugin file. It activates but nothing happens. The menu is not created.

 *  Activate plugin
 *    create admin menu
 *    create more stuff
register_activation_hook(__FILE__, 'markmast_activate');

function markmast_activate() {
  add_action('admin_menu', 'markmast_create_admin_menu');
  function markmast_create_admin_menu() {
    add_menu_page( 'Marketing Master', 'Marketing Master Settings', 'manage_options', 'custom');

1 Answer 1


WP needs all the required arguments - you skipped the one that tells it either a PHP file to use for output, or a function to run.

From the Developer Site:

 * Register a custom menu page.
function wpdocs_register_my_custom_menu_page(){
        __( 'Custom Menu Title', 'textdomain' ),
        'custom menu',
        plugins_url( 'myplugin/images/icon.png' ),
add_action( 'admin_menu', 'wpdocs_register_my_custom_menu_page' );
 * Display a custom menu page
function my_custom_menu_page(){
    esc_html_e( 'Admin Page Test', 'textdomain' );  

The 5th argument in add_menu_page() is the name of a custom function, which is then defined below.

  • I figured out the issue. It wasn't the callback but it was the fact that when a plugin is activated it then is redirected and the page is refreshed. It caused the action hook not to run, however add_option() will run.. I fixed it by adding a setting in the options table that will tell me when the plugin is activated or deactivated. example: add_option('is_activated', 'true') then do a check if(get_option('is_activated') == true) { logic here ... } . Hopefully this helps someone else struggling with the same issue. Thanks for the help.
    – Kustom
    Aug 9, 2021 at 16:35

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.