PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.0
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.0
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 5.6.1 All 34 releases
automatorwp / integrations / armember / includes / actions / add-membership.php

add-membership.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 6.0.0, at integrations/armember/includes/actions/add-membership.php

86 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Add Membership
4 *
5 * @package AutomatorWP\Integrations\ARMember\Actions\Add_Membership
6 * @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]>
7 * @since 1.0.0
8 */
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 class AutomatorWP_ARMember_Add_Membership extends AutomatorWP_Integration_Action {
13
14 public $integration = 'armember';
15 public $action = 'armember_add_membership';
16
17 /**
18 * Register the trigger
19 *
20 * @since 1.0.0
21 */
22 public function register() {
23
24 automatorwp_register_action( $this->action, array(
25 'integration' => $this->integration,
26 'label' => __( 'Add user to membership plan', 'automatorwp' ),
27 'select_option' => __( 'Add user to <strong>membership</strong> plan', 'automatorwp' ),
28 /* translators: %1$s: Referral. */
29 'edit_label' => sprintf( __( 'Add user to %1$s', 'automatorwp' ), '{plan}' ),
30 /* translators: %1$s: Referral. */
31 'log_label' => sprintf( __( 'Add user to %1$s', 'automatorwp' ), '{plan}' ),
32 'options' => array(
33 'plan' => automatorwp_utilities_ajax_selector_option( array(
34 'field' => 'plan',
35 'option_default' => __( 'Plan', 'automatorwp' ),
36 'name' => __( 'Plan:', 'automatorwp' ),
37 'action_cb' => 'automatorwp_armember_get_plans',
38 'options_cb' => 'automatorwp_armember_options_cb_plan',
39 'placeholder' => 'Select a plan',
40 'default' => ''
41 ) ),
42 ),
43 ) );
44
45 }
46
47 /**
48 * Action execution function
49 *
50 * @since 1.0.0
51 *
52 * @param stdClass $action The action object
53 * @param int $user_id The user ID
54 * @param array $action_options The action's stored options (with tags already passed)
55 * @param stdClass $automation The action's automation object
56 */
57 public function execute( $action, $user_id, $action_options, $automation ) {
58
59 global $arm_subscription_plans;
60
61 // Shorthand
62 $plan_id = $action_options['plan'];
63
64 // Bail if no plan
65 if ( empty ( $plan_id ) ) {
66 return;
67 }
68
69 $membership_data = array(
70 'arm_user_plan' => $plan_id,
71 'payment_gateway' => 'manual',
72 'arm_selected_payment_mode' => 'manual_subscription',
73 'arm_primary_status' => 1,
74 'arm_secondary_status' => 0,
75 'arm_subscription_start_date' => date( 'm/d/Y' ),
76 'arm_user_import' => true,
77 );
78
79 $admin_save_flag = 1;
80 do_action( 'arm_member_update_meta', $user_id, $membership_data, $admin_save_flag );
81
82 }
83
84 }
85
86 new AutomatorWP_ARMember_Add_Membership();