Title: Singleton pattern
Last modified: September 11, 2018

---

# Singleton pattern

 *  [Laszlo](https://wordpress.org/support/users/laszloszalvak/)
 * (@laszloszalvak)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/singleton-pattern/)
 * Hi!
 * We are from Nextend Social Login and we had a received some requests to make 
   our plugin compatible with Woocommerce User Email Verification.
 * By default Woocommerce User Email Verification prevented the login with Nextend
   Social Login as well.
 * We made a fix for this problem and we also needed to remove the action that sends
   the email verification when the user connects with a provider like Facebook, 
   Google etc…
 * The problem is that, there is an issue with the singleton pattern of the class
   XLWUEV_Woocommerce_Confirmation_Email_Public in wp-content/plugins/woo-confirmation-
   email/public/class-xlwuev-woocommerce-confirmation-email-public.php.
 * **The description of the issue:**
    We are removing the action like:
 *     ```
       remove_action('user_register', array(
                       XLWUEV_Woocommerce_Confirmation_Email_Public::instance(),
                       'custom_form_user_register'
                   ), 10);
       ```
   
 * However XLWUEV_Woocommerce_Confirmation_Email_Public::instance() creates a new
   instance every time when it is called, instead of referring to the original one.
 * According to the instance function:
 *     ```
       public static function instance() {
       		if ( null == self::$ins ) {
       			return new self;
       		}
   
       		return self::$ins;
       	}
       ```
   
 * it should refer to the original one, if one already exists.
 * The fix for this problem is that to add
    `self::$ins = $this;` at the constructor
   like:
 *     ```
       public function __construct() {
       	    self::$ins = $this;
       ...
       }
       ```
   
 * We are looking forward to your feedback.
 * Best regards,
    Laszlo.

The topic ‘Singleton pattern’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/woo-confirmation-email_e9dce5.svg)
 * [User Email Verification for WooCommerce](https://wordpress.org/plugins/woo-confirmation-email/)
 * [Support Threads](https://wordpress.org/support/plugin/woo-confirmation-email/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-confirmation-email/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-confirmation-email/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-confirmation-email/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Laszlo](https://wordpress.org/support/users/laszloszalvak/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/singleton-pattern/)
 * Status: not resolved