| 1 |
<?php |
| 2 |
/** |
| 3 |
* Register |
| 4 |
* |
| 5 |
* @package AutomatorWP\Integrations\WordPress\Triggers\Register |
| 6 |
* @author AutomatorWP <contact@automatorwp.com>, Ruben Garcia <rubengcdev@gmail.com> |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
class AutomatorWP_WordPress_Register extends AutomatorWP_Integration_Trigger { |
| 13 |
|
| 14 |
/** |
| 15 |
* Initialize the trigger |
| 16 |
* |
| 17 |
* @since 1.0.0 |
| 18 |
*/ |
| 19 |
public function __construct( $integration ) { |
| 20 |
|
| 21 |
$this->integration = $integration; |
| 22 |
$this->trigger = $integration . '_register'; |
| 23 |
|
| 24 |
parent::__construct(); |
| 25 |
|
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Register the trigger |
| 30 |
* |
| 31 |
* @since 1.0.0 |
| 32 |
*/ |
| 33 |
public function register() { |
| 34 |
|
| 35 |
automatorwp_register_trigger( $this->trigger, array( |
| 36 |
'integration' => $this->integration, |
| 37 |
'label' => __( 'User registers to the site', 'automatorwp' ), |
| 38 |
'select_option' => __( 'User <strong>registers</strong> to the site', 'automatorwp' ), |
| 39 |
'edit_label' => __( 'User registers to the site', 'automatorwp' ), |
| 40 |
'log_label' => __( 'User registers', 'automatorwp' ), |
| 41 |
'action' => 'user_register', |
| 42 |
'function' => array( $this, 'listener' ), |
| 43 |
'priority' => 10, |
| 44 |
'accepted_args' => 1, |
| 45 |
'options' => array( |
| 46 |
// No options |
| 47 |
), |
| 48 |
'tags' => array( |
| 49 |
// No tags |
| 50 |
) |
| 51 |
) ); |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Trigger listener |
| 57 |
* |
| 58 |
* @since 1.0.0 |
| 59 |
* |
| 60 |
* @param int $user_id New registered user ID |
| 61 |
*/ |
| 62 |
public function listener( $user_id ) { |
| 63 |
|
| 64 |
automatorwp_trigger_event( array( |
| 65 |
'trigger' => $this->trigger, |
| 66 |
'user_id' => $user_id, |
| 67 |
) ); |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
new AutomatorWP_WordPress_Register( 'wordpress' ); |
| 74 |
new AutomatorWP_WordPress_Register( 'users' ); |