Developers – Action Hooks and Filters

  • before_wpgens_raf_init – Runs before the RAF plugin init
do_action('before_wpgens_raf_init');
  • after_wpgens_raf_init – Runs after the RAF plugin init
do_action('after_wpgens_raf_init');
  • gens_after_referral_url – Runs after displaying the referral URL
do_action('gens_after_referral_url');
  • wpgens_raf_new_user_referral_id – Fires when a new user gets a referral ID
do_action('wpgens_raf_new_user_referral_id', $referral_id, $user_id);
  • gens_new_user_registration – Fires on new user registration
do_action('gens_new_user_registration', $referral_id, $user_id);
  • new_raf_data – Records data for analytics purposes
// New order event
do_action('new_raf_data', 'new_order', array(
    'user' => $user_id,
    'referral' => $referrer_id,
    'order' => $order_id,
    'generate' => $generate_bool,
    'increase_referrals' => $increase_bool
));

// New coupon event
do_action('new_raf_data', 'new_coupon', array(
    'user' => $user_id,
    'order' => $order_id,
    'coupon_id' => $coupon_id
));

// Email sent event
do_action('new_raf_data', 'email_sent', array(
    'email' => $email,
    'subject' => $subject,
    'type' => $type,
    'coupon_code' => $coupon_code
));

// Coupon applied event
do_action('new_raf_data', 'coupon_applied', array(
    'user' => $user_id,
    'referral' => $referrer_id,
    'type' => $type // 'code' or 'link'
));

// User referred event
do_action('new_raf_data', 'user_referred', array(
    'user' => $user_id,
    'referrer' => $referrer_id
));

// Subscription renewal event
do_action('new_raf_data', 'subscription_renewal', array(
    'user' => $user_id,
    'order' => $order_id
));
  • gens_before_generate_user_coupon – Fires before a coupon is generated
do_action('gens_before_generate_user_coupon', $user_id, $type, $order);
  • gens_after_generate_user_coupon – Fires after a coupon is generated
do_action('gens_after_generate_user_coupon', $user_id, $type, $order, $coupon_id);
  • gens_raf_send_referral_coupon – Fires after sending a referral coupon email
do_action('gens_raf_send_referral_coupon', $email, $coupon_code, $type);
  • gens_raf_auto_apply_coupon – Fires when a coupon is automatically applied
do_action('gens_raf_auto_apply_coupon', $referrer_id);
  • gens_raf_checkout_check – Fires during checkout coupon validation
do_action('gens_raf_checkout_check', $guest_coupon_code, $referrer_id);
  • send_referral_notification_email_event – Fires when a referral notification email is sent
do_action('send_referral_notification_email_event', $user_id);
  • wpgens_raf_order_status – Filter the order status that triggers coupon generation
add_action('woocommerce_order_status_' . apply_filters('wpgens_raf_order_status', 'completed'), array(__CLASS__, 'gens_maybe_create_send_coupon'), 10, 1);

= Filter Hooks =

  • wpgens_raf_locate_template – Filter template location
$template = apply_filters('wpgens_raf_locate_template', $template, $template_path, $guest_view);
  • gens_raf_tab_title – Filter the title of the RAF tab in My Account
$title = apply_filters("gens_raf_tab_title", __('Refer a Friend', 'gens-raf'));
  • gens_raf_coupon_prefix – Filter the coupon prefix
$prefix = apply_filters('gens_raf_coupon_prefix', $this->type === "friend" ? 'gens_raf_friend' : 'gens_raf', $this->type);
  • gens_raf_generate_coupon – Control whether to generate a coupon
$generate = apply_filters("gens_raf_generate_coupon", true, $order_id);
  • wpgens_raf_code – Filter the referral code
$referral_id = apply_filters('wpgens_raf_code', $referral_id);
  • wpgens_raf_link – Filter the referral link
$refLink = apply_filters('wpgens_raf_link', $refLink, $referral_id, $type);
  • wpgens_raf_tab_disable – Control whether to disable RAF tab on product pages
$tabs_hide = apply_filters('wpgens_raf_tab_disable', $this->settings_field_active('gens_raf_tabs_disable'));
  • gens_raf_coupon_data – Filter coupon data
$data = apply_filters('gens_raf_coupon_data', array(
    'discount_type' => $discount_type,
    'amount' => $amount,
    'free_shipping' => $free_shipping,
    'minimum_amount' => $minimum_amount,
    'individual_use' => $individual_use === "yes" ? true : false,
    'exclude_sale_items' => $exclude_sale_items === "yes" ? true : false,
    'product_ids' => array_map('intval', (array) explode(',', $product_ids)),
    'excluded_product_ids' => array_map('intval', (array) explode(',', $exclude_product_ids)),
    'product_categories' => array_map('intval', (array) $product_categories),
    'excluded_product_categories' => array_map('intval', (array) $exclude_product_categories),
    'id' => true
), $coupon_id, $user_id, $coupon_code);
  • gens_raf_minimum_order_amount – Filter minimum order amount
$minimum_amount = apply_filters('gens_raf_minimum_order_amount', get_option('gens_raf_min_ref_order'), $order_id);
  • gens_raf_custom_message – Filter the custom message for order info
$custom_msg = apply_filters('gens_raf_custom_message', $custom_msg);
  • gens_raf_order_info – Filter the RAF order info
$raf_info = apply_filters("gens_raf_order_info", $raf_info, $order, $referrer_id);
  • gens_raf_coupon_applied – Filter the message shown when a coupon is applied
$message = apply_filters("gens_raf_coupon_applied", __('Coupon Applied!', 'gens-raf'));
  • gens_raf_should_remove_coupon – Control whether a coupon should be removed from cart
$should_remove_coupon = apply_filters('gens_raf_should_remove_coupon', $should_remove_coupon, $guest_coupon_code, $referrer_id);
  • gens_raf_coupon_removal_message – Filter the coupon removal message
$coupon_removal_message = apply_filters('gens_raf_coupon_removal_message', __('The coupon has been removed from your cart. You are an existing customer and are not entitled to a referral discount.', 'gens-raf'));
  • gens_raf_fraud_order_status – Filter the order statuses used for fraud detection
$statuses = apply_filters('gens_raf_fraud_order_status', array_keys($all_statuses));
  • wpgens_raf_title – Filter the title displayed on My Account page
$title = apply_filters('wpgens_raf_title', __('Unused Refer a Friend Coupons', 'gens-raf'));
  • gens_raf_coupons_query – Filter the query for getting user’s unused coupons
$args = apply_filters("gens_raf_coupons_query", array(
    'posts_per_page' => -1,
    'post_type' => 'shop_coupon',
    'post_status' => 'publish',
    'meta_query' => array(
        array(
            'key' => 'customer_email',
            'value' => $user_email,
            'compare' => 'LIKE'
        )
    ),
), $user_email);
  • gens_raf_points_amount – Filter the points amount for Points & Rewards integration
$points = apply_filters("gens_raf_points_amount", get_option('wc_points_rewards_wpgens_raf'), $order);
  • wpgens_raf_disallowed_email_roles – Filter user roles that should not receive referral emails
$disallowed_roles = apply_filters('wpgens_raf_disallowed_email_roles', array());
  • wpgens_subscription_renewal_coupons_number – Filter the number of coupons that can be used for subscription renewals
$posts_per_page = apply_filters('wpgens_subscription_renewal_coupons_number', 999);
  • gens_raf_discount_type – Filter the coupon discount type
$discount_type = apply_filters($prefix . "_discount_type", $discount_type);
  • gens_raf_coupon_amount – Filter the coupon amount
$amount = apply_filters($prefix . "_coupon_amount", $amount, $order_id);
  • wpgens_user_has_orders_status_list – Filter the order statuses used to check if a user has orders
$status_list = apply_filters('wpgens_user_has_orders_status_list', array('wc-processing', 'wc-completed'));
Browse our plugins

Lightweight WooCommerce plugins built for speed. No bloat, no frameworks -- just clean code that works.

View all plugins