event_merge_tag_groups = array( 'aff_affiliate', 'bwf_contact' ); $this->optgroup_label = esc_html__( 'AffiliateWP', 'wp-marketing-automations-pro' ); $this->event_name = esc_html__( 'Application Sign Up', 'wp-marketing-automations-pro' ); $this->event_desc = esc_html__( 'This event runs after an affiliate signed up.', 'wp-marketing-automations-pro' ); $this->event_rule_groups = array( 'affiliatewp', 'bwf_contact_segments', 'bwf_contact', 'bwf_contact_fields', 'bwf_contact_user', 'bwf_contact_wc', 'bwf_contact_geo', 'bwf_engagement', 'bwf_broadcast' ); $this->priority = 10; $this->customer_email_tag = '{{affwp_affiliate_email}}'; $this->v2 = true; } public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } public function load_hooks() { add_action( 'affwp_register_user', array( $this, 'affiliate_created' ), 999, 3 ); add_action( 'affwp_auto_register_user', array( $this, 'affiliate_created' ), 999, 3 ); } /** * @param $affiliate_id * @param $status * @param $args */ public function affiliate_created( $affiliate_id, $status, $args ) { $this->affiliate_id = $affiliate_id; $this->status = $status; $this->process(); } /** * Make the required data for the current event and send it asynchronously. */ public function process() { $data = $this->get_default_data(); $data['affiliate_id'] = $this->affiliate_id; $data['status'] = $this->status; $this->send_async_call( $data ); } /** * Registers the tasks for current event. * * @param $automation_id * @param $integration_data * @param $event_data */ public function register_tasks( $automation_id, $integration_data, $event_data ) { if ( ! is_array( $integration_data ) ) { return; } $data_to_send = $this->get_event_data(); $this->create_tasks( $automation_id, $integration_data, $event_data, $data_to_send ); } public function get_event_data() { $data_to_send = [ 'global' => [] ]; $data_to_send['global']['affiliate_id'] = $this->affiliate_id; $data_to_send['global']['status'] = $this->status; $data_to_send['global']['user_id'] = $this->user_id; return $data_to_send; } /** * Make the view data for the current event which will be shown in task listing screen. * * @param $global_data * * @return false|string */ public function get_task_view( $global_data ) { ob_start(); $affiliate_id = isset( $global_data['affiliate_id'] ) ? $global_data['affiliate_id'] : 0; ?>