Undefined variable $msg_to_display , “roles” bool, undefined, PHP 8.1
-
Just upgraded our site to PHP 8.1 and getting some error messages loading various pages when this plugin is activated:
Undefined variable $msg_to_display at wp-content/plugins/discount-with-first-purchase-for-woocommerce/Front/plgfyqdp_main_front.php:1119)
If I change the line from
$$msg_to_display='';
to$msg_to_display='';
it works. Not sure if this is the best fix.Was also getting
Attempt to read property \"roles\" on bool at wp-content/plugins/discount-with-first-purchase-for-woocommerce/Front/plgfyqdp_main_front.php:966)
and
Attempt to read property \"roles\" on bool at wp-content/plugins/discount-with-first-purchase-for-woocommerce/Front/plgfyqdp_main_front.php:1127
Fixed by changing from:
$user_roles=$user_meta->roles;
toif (isset($user_meta->roles)) { $user_roles=$user_meta->roles; } else { $user_roles = []; }
Also getting:
Undefined array key \"applied_on\" at wp-content/plugins/discount-with-first-purchase-for-woocommerce/Front/plgfyqdp_main_front.php:1047
and
Undefined array key \"applied_on\" at wp-content/plugins/discount-with-first-purchase-for-woocommerce/Front/plgfyqdp_main_front.php:448
Fixed by changing from:
} else if ('whole' == $value['applied_on']) {
to
} else if (isset($value['applied_on']) && 'whole' == $value['applied_on']) {
- The topic ‘Undefined variable $msg_to_display , “roles” bool, undefined, PHP 8.1’ is closed to new replies.