PMP_MEMBERSHIPPURCH::define_trigger()

Define and register the trigger by pushing it into the Automator object


Source Source

File: src/integrations/paid-memberships-pro/triggers/pmp-membershippurch.php

	public function define_trigger() {



		$options = Automator()->helpers->recipe->paid_memberships_pro->options->all_memberships( esc_attr__( 'Membership', 'uncanny-automator' ) );

		$options['options'] = array( '-1' => esc_attr__( 'Any membership', 'uncanny-automator' ) ) + $options['options'];

		$trigger = array(
			'author'              => Automator()->get_author_name( $this->trigger_code ),
			'support_link'        => Automator()->get_author_support_link( $this->trigger_code, 'integration/paid-memberships-pro/' ),
			'integration'         => self::$integration,
			'code'                => $this->trigger_code,
			/* translators: Logged-in trigger - Paid Memberships Pro */
			'sentence'            => sprintf( esc_attr__( 'A user purchases {{a membership:%1$s}}', 'uncanny-automator' ), $this->trigger_meta ),
			/* translators: Logged-in trigger - Paid Memberships Pro */
			'select_option_name'  => esc_attr__( 'A user purchases {{a membership}}', 'uncanny-automator' ),
			'action'              => 'pmpro_after_checkout',
			'priority'            => 99,
			'accepted_args'       => 2,
			'validation_function' => array( $this, 'pmpro_payment_completed' ),
			'options'             => [
				$options,
			],
		);

		Automator()->register->trigger( $trigger );

		return;
	}