PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.1
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.1
6.0.4 6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 All 35 releases
automatorwp / integrations / affiliatepress / includes / triggers / user-registers-affiliate.php

user-registers-affiliate.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 6.0.1, at integrations/affiliatepress/includes/triggers/user-registers-affiliate.php

63 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * User Registers as Affiliate Trigger
4 *
5 * @package AutomatorWP\Integrations\AffiliatePress\Triggers\User_Registers_Affiliate
6 * @since 1.0.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) exit;
10
11 class AutomatorWP_AffiliatePress_User_Registers_Affiliate extends AutomatorWP_Integration_Trigger {
12
13 public $integration = 'affiliatepress';
14 public $trigger = 'affiliatepress_user_registers_affiliate';
15
16 /**
17 * Register the trigger
18 *
19 * @since 1.0.0
20 * @return void
21 */
22 public function register() {
23
24 automatorwp_register_trigger( $this->trigger, array(
25 'integration' => $this->integration,
26 'label' => __( 'User becomes an affiliate', 'automatorwp' ),
27 'select_option' => __( 'User <strong>becomes</strong> an affiliate', 'automatorwp' ),
28 'edit_label' => __( 'User becomes an affiliate', 'automatorwp' ),
29 'log_label' => __( 'User becomes an affiliate', 'automatorwp' ),
30 'action' => 'affiliatepress_after_signup_affiliate',
31 'function' => array( $this, 'listener' ),
32 'priority' => 10,
33 'accepted_args' => 1,
34 'options' => array(),
35 'tags' => array()
36 ));
37 }
38
39 /**
40 * Trigger listener
41 *
42 * @since 1.0.0
43 *
44 * @param int $affiliate_id
45 */
46 public function listener( $affiliate_id ) {
47
48 $user_id = automatorwp_affiliatepress_get_user_id( $affiliate_id );
49
50 // Bail if no user id
51 if ( empty( $user_id ) ) {
52 return;
53 }
54
55 automatorwp_trigger_event( array(
56 'trigger' => $this->trigger,
57 'user_id' => $user_id,
58 'affiliate_id' => $affiliate_id,
59 ) );
60 }
61 }
62
63 new AutomatorWP_AffiliatePress_User_Registers_Affiliate();