settings = $settings; $this->subscriber_actions = $subscriber_actions; } function extendForm() { $label = $this->settings->get( 'subscribe.on_register.label', WPFunctions::get()->__('Yes, please add me to your mailing list.', 'mailpoet') ); print '

'; } function onMultiSiteRegister($result) { if (empty($result['errors']->errors)) { if ( isset($_POST['mailpoet']['subscribe_on_register']) && (bool)$_POST['mailpoet']['subscribe_on_register'] === true ) { $this->subscribeNewUser( $result['user_name'], $result['user_email'] ); } } return $result; } function onRegister( $user_login, $user_email = null, $errors = null ) { if ( empty($errors->errors) && isset($_POST['mailpoet']['subscribe_on_register']) && (bool)$_POST['mailpoet']['subscribe_on_register'] === true ) { $this->subscribeNewUser( $user_login, $user_email ); } } private function subscribeNewUser($name, $email) { $segment_ids = $this->settings->get( 'subscribe.on_register.segments', [] ); if (!empty($segment_ids)) { $this->subscriber_actions->subscribe( array( 'email' => $email, 'first_name' => $name ), $segment_ids ); } } }