0

I'm trying to add an admin sub-level menu on WordPress. The menu link is working fine but the page which I want to show is throwing an error.

error:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'print_admin_config' not found or invalid function name in /var/www/html/woocommerce-print/wp-includes/class-wp-hook.php on line 286

Hook:

add_action( 'admin_menu', 'print_admin_menu' );

function print_admin_menu() {
    add_options_page( 'Print Configuration', 'Print Configuration', 'manage_options', 
    'woocommerce-print/admin/print-admin-config.php', 'print_admin_config', 'dashicons-tickadmin-generic', 31 );
}

Callback function (woocommerce-print/admin/print-admin-config.php):

<?php
function print_admin_config(){
    ?>
    <div class="wrap">
        <h2>Welcome To My Plugin</h2>
    </div>
    <?php
}
4
  • @JacobPeattie, my print_admin_config() is in woocommerce-print/admin directory and the file in which my hook is written is also in the same directory Feb 6, 2018 at 13:00
  • That's not how PHP works. You still need to include the file. Feb 6, 2018 at 13:01
  • then can you show me how to do it? Feb 6, 2018 at 13:04
  • Check add_options_page() arguments. You have one unnecessary.
    – Max Yudin
    Feb 6, 2018 at 13:04

1 Answer 1

0

Got it working like this:

function print_admin_menu() {
    add_options_page( 'Print Configuration', 'Print Configuration', 'manage_options', 
    'print_admin_config_page', 'my_callback' );
}

function my_callback(){
    ?>
    <div class="wrap">
        <h2>Welcome To My Plugin</h2>
    </div>
    <?php
}

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.

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