Title: Undefined variable $msg_to_display , &#8220;roles&#8221; bool, undefined, PHP 8.1
Last modified: December 2, 2022

---

# Undefined variable $msg_to_display , “roles” bool, undefined, PHP 8.1

 *  Resolved [emboldtyler](https://wordpress.org/support/users/emboldtyler/)
 * (@emboldtyler)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/undefined-variable-msg_to_display/)
 * 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;` to
 *     ```
       if (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']) {`
    -  This topic was modified 3 years, 5 months ago by [emboldtyler](https://wordpress.org/support/users/emboldtyler/).
    -  This topic was modified 3 years, 5 months ago by [emboldtyler](https://wordpress.org/support/users/emboldtyler/).
    -  This topic was modified 3 years, 5 months ago by [emboldtyler](https://wordpress.org/support/users/emboldtyler/).
    -  This topic was modified 3 years, 5 months ago by [emboldtyler](https://wordpress.org/support/users/emboldtyler/).
      Reason: Adding additional errors/fixes

Viewing 1 replies (of 1 total)

 *  Plugin Author [Vidish](https://wordpress.org/support/users/vidishp/)
 * (@vidishp)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/undefined-variable-msg_to_display/#post-16260010)
 * [@emboldtyler](https://wordpress.org/support/users/emboldtyler/) I think you 
   have mistaken to search plugin. This plugin is not developed by us. You need 
   to reach out to correct author.
 * Thank you!
    Vidish

Viewing 1 replies (of 1 total)

The topic ‘Undefined variable $msg_to_display , “roles” bool, undefined, PHP 8.1’
is closed to new replies.

 * ![](https://ps.w.org/first-order-discount-woocommerce/assets/icon-128x128.png?
   rev=2830027)
 * [First Order Discount Woocommerce](https://wordpress.org/plugins/first-order-discount-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/first-order-discount-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/first-order-discount-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/first-order-discount-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/first-order-discount-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/first-order-discount-woocommerce/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Vidish](https://wordpress.org/support/users/vidishp/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/undefined-variable-msg_to_display/#post-16260010)
 * Status: resolved