Title: limit user
Last modified: August 13, 2017

---

# limit user

 *  Resolved [movahedian1](https://wordpress.org/support/users/movahedian1/)
 * (@movahedian1)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/limit-user-3/)
 * hi
    is there any way to limit coupon that user get from refer link? i mean admin
   can set maximum coupon that user can get from his/her refer link and when rich
   to max user can not get coupon until user use his/her coupon. thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [movahedian1](https://wordpress.org/support/users/movahedian1/)
 * (@movahedian1)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/limit-user-3/#post-9407764)
 * hi
    i add this code in class-gens-raf-public.php and change function gens_create_send_coupon
   and work:
 *     ```
       public function gens_create_send_coupon($order_id) {
       		$rafID = esc_attr(get_post_meta( $order_id, '_raf_id', true));
       		// Get id of user that made order so that user cant use his own ref link.
       		$order = new WC_Order( $order_id );
       		$order_user_id = $order->get_user_id();
       		$gens_users = get_users( array(
       			"meta_key" => "gens_referral_id",
       			"meta_value" => $rafID,
       			"number" => 1, 
       			"fields" => "ID"
       		) );
       		$user_id = $gens_users[0];
   
                       // added code
       		$user_info = get_userdata($user_id);
       		$user_email = $user_info->user_email;
       		$couponargs = array( 'post_type' => 'shop_coupon','posts_per_page' => -1, 'meta_key' => 'customer_email', 'meta_value' => $user_email);
       		$mycoupons = get_posts( $couponargs );
       		$count = count($mycoupons);
       		//end
   
       		// user ref exists, refID as well, and user is not using his own referral link ? If all good, proceed.
       		if ( $gens_users && !empty($rafID) && ($user_id != $order_user_id) && $count < 2) {
       			// Generate Coupon and returns it
       			$coupon_code = $this->generate_coupons( $user_id  ); 
       			// Send via Email
       			$this->gens_send_email( $user_id, $coupon_code );
       		}
       		return $order_id;
       	}
       ```
   
 * but i want a way to not change in core of plugin.
    please help thanks
    -  This reply was modified 8 years, 10 months ago by [movahedian1](https://wordpress.org/support/users/movahedian1/).
 *  Plugin Author [Goran87](https://wordpress.org/support/users/goran87/)
 * (@goran87)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/limit-user-3/#post-9454652)
 * Currently, there is no filter added in a free plugin, only premium, but I’ll 
   add it in the future so once it’s done, you can just copy your code to the new
   filter.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘limit user’ is closed to new replies.

 * ![](https://ps.w.org/refer-a-friend-for-woocommerce-by-wpgens/assets/icon-256x256.
   png?rev=1276153)
 * [Refer A Friend for WooCommerce by WPGens](https://wordpress.org/plugins/refer-a-friend-for-woocommerce-by-wpgens/)
 * [Support Threads](https://wordpress.org/support/plugin/refer-a-friend-for-woocommerce-by-wpgens/)
 * [Active Topics](https://wordpress.org/support/plugin/refer-a-friend-for-woocommerce-by-wpgens/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/refer-a-friend-for-woocommerce-by-wpgens/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/refer-a-friend-for-woocommerce-by-wpgens/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Goran87](https://wordpress.org/support/users/goran87/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/limit-user-3/#post-9454652)
 * Status: resolved