Undefined offset error for $user_role
-
I am getting thie message:
PHP Notice: Undefined offset: 0 in /home/dev2couk22/public_html/wordpress/wp-content/plugins/advanced-woo-search/includes/class-aws-cache.php on line 81
The user role array is being created correctly, but the primary role in the user’s roles array does not always have the [0] index, e.g. the user’s role array may be:
Array( [4] => ‘product_manager’);
So, by using $role[0] (which doesn’t exist), an error is generated.
To get round this, replace line [81] with:
$user_role =array_values($role)[0];
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Undefined offset error for $user_role’ is closed to new replies.