如何删除此警告“警告:array_shift()期望参数1为数组,从...给出的null从我的网站顶部开始?

问题描述 投票:-1回答:2

我正在Wordpress中使用Visual Composer插件。我试图更改标题的bg颜色。外观>自定义无效,因此我安装了名为“简单自定义CSS”的插件。我将CSS添加到了此插件,然后标题没问题,但我在网站顶部收到了此警告:

警告:array_shift()期望参数1为数组,在中给出null/home/dejpaad/public_html/wp-content/themes/businext/myfuncations.php在第411行

http://dejpaad.com/

这是警告所谈论的行:

/**
Allow customers to access wp-admin
*/
global $current_user; 
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
if($user_role == "stgh_client") {
    add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
}
php wordpress visual-composer
2个回答
0
投票
$user_roles = $current_user->roles;
if (is_array($user_roles) && array_shift($user_roles) == "stgh_client") {
    add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
}

-1
投票

您可以关闭调试以便忽略此警告,使其不会出现在您的网站上。

找到您的WordPress网站的wp-config.php文件编辑文件并找到WP_DEBUG的定义它看起来会像这样:define('WP_DEBUG',true);

将其更改为:define('WP_DEBUG',false);保存文件,然后重新加载您的网站。

希望这对您有用。

© www.soinside.com 2019 - 2024. All rights reserved.