Skip to content
Advertisement

WordPress debug – call_user_func_array() expects parameter 1 to be a valid callback

I’ve just updated my WordPress to a new version & I’m getting this error:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘restrict_admin’ not found or invalid function name in /home/burngeopk/public_html/members/wp-includes/class-wp-hook.php on line 287

There is only 1 string that has restrict_admin in my theme’s function.php. I am looking for guidance how to rephrase this string to make it work.

add_action( 'admin_init', 'restrict_admin', 1 );
function my_function_admin_bar($content) {
  return ( current_user_can( 'administrator' ) ) ? $content : false;
}

Advertisement

Answer

It looks like the function restrict_admin does not exist anymore.

Try to add it back to your theme? Here its source code:

function restrict_admin() {
 
    if ( ! current_user_can( 'manage_options' ) && ( ! wp_doing_ajax() ) ) {
        wp_die( __( 'You are not allowed to access this part of the site' ) );
    }
}

Source: https://developer.wordpress.org/reference/hooks/admin_init/

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement