PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 3, 2022

[FIXED] How to remove this warning" Warning: array_shift() expects parameter 1 to be array, null given in ..." from the top of my website?

 August 03, 2022     php, visual-composer, wordpress     No comments   

Issue

I am using Visual Composer plugin in Wordpress. I was trying to change the header's bg color. The appearance>customize didn't work, so I installed a plugin named "Simple Custom CSS". I added the CSS to this plugin, then the header is ok but I get this Warning on the top of the website :

Warning: array_shift() expects parameter 1 to be array, null given in /home/dejpaad/public_html/wp-content/themes/businext/myfuncations.php on line 411

http://dejpaad.com/

This is the line the warning is talking about:

/**
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' );
}

Solution

$user_roles = $current_user->roles;
if (is_array($user_roles) && array_shift($user_roles) == "stgh_client") {
    add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
}


Answered By - user10767914
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing