public function execute()
 {
     if (!$this->validate()) {
         return;
     }
     $comment_id = $this->keys[0];
     $comment = get_comment($comment_id);
     if (!$comment) {
         Prompt_Logging::add_error('register_subscribe_comment_invalid', __('Couldn\'t find the original registration information for a new user.', 'Postmatic'), array('keys' => $this->keys, 'message' => $this->message));
         return;
     }
     $lists = $this->resolve_lists($comment);
     $user_data = get_comment_meta($comment_id, self::$user_data_meta_key, true);
     $email = $comment->comment_author_email;
     $subscriber = get_user_by('email', $email);
     $opted_in_list = $this->opted_in_list($lists);
     if (!$subscriber and !$opted_in_list) {
         if (self::stop_resending($comment)) {
             return;
         }
         Prompt_Subscription_Mailing::send_agreement($lists, $email, $user_data, $resend_command = $this);
         return;
     }
     if (!$opted_in_list) {
         // The user has already been created, probably via a different reply. Just ignore this nonsense reply.
         return;
     }
     $subscriber_id = $subscriber ? $subscriber->ID : Prompt_User_Handling::create_from_email($email);
     if (is_wp_error($subscriber_id)) {
         Prompt_Logging::add_error('register_subscribe_user_creation_failure', __('Failed to create a new user from an agreement reply email.', 'Postmatic'), array('keys' => $this->keys, 'user_data' => $user_data, 'message' => $this->message, 'error' => $subscriber_id));
         return;
     }
     if (!$subscriber and $user_data) {
         $user_data['ID'] = $subscriber_id;
         wp_update_user($user_data);
         $origin = new Prompt_Subscriber_Origin(array('source_label' => $opted_in_list->subscription_object_label(), 'source_url' => $opted_in_list->subscription_url(), 'agreement' => $this->message));
         $prompt_user = new Prompt_User($subscriber_id);
         $prompt_user->set_subscriber_origin($origin);
         do_action('prompt/register_subscribe_command/created_user', $prompt_user->get_wp_user());
     }
     if (!$opted_in_list->is_subscribed($subscriber_id)) {
         $opted_in_list->subscribe($subscriber_id);
         Prompt_Subscription_Mailing::send_subscription_notification($subscriber_id, $opted_in_list);
     }
     // TODO: remove our pre registration comment?
 }
 /**
  * Import a user.
  *
  * @param string $subscriber The subscriber's email address
  * @param object|\Prompt_Post Post subscribe object for current post.
  */
 protected function import($subscriber, $object)
 {
     $existing_user = get_user_by('email', $subscriber);
     if ($existing_user and $object->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if (!$existing_user) {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber);
     } else {
         $subscriber_id = $existing_user->ID;
     }
     $subscribed = $object->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Subscribe 2 Comments Reloaded Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
 /**
  * Import a MailPoet subscriber.
  *
  * @since 1.0.0
  * @param array $subscriber
  */
 protected function import($subscriber)
 {
     $existing_user = get_user_by('email', $subscriber['email']);
     if ($existing_user and $this->target_list->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if (!$existing_user) {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber['email']);
         wp_update_user(array('ID' => $subscriber_id, 'first_name' => $subscriber['firstname'], 'last_name' => $subscriber['lastname']));
     } else {
         $subscriber_id = $existing_user->ID;
     }
     $this->target_list->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Mailpoet Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
 public static function after_form()
 {
     if (!Prompt_Core::$options->get('enable_comment_delivery') or empty(self::$prompt_post)) {
         return;
     }
     $current_user = Prompt_User_Handling::current_user();
     if (!$current_user or !self::$prompt_post->is_subscribed($current_user->ID)) {
         return;
     }
     echo html('div class="prompt-unsubscribe"', html('div class=".loading-indicator" style="display: none;"', html('img', array('src' => path_join(Prompt_Core::$url_path, 'media/ajax-loader.gif')))), html('p', __('You are subscribed to new comments on this post.', 'Postmatic')), scbForms::input(array('type' => 'submit', 'name' => self::UNSUBSCRIBE_ACTION, 'value' => __('Unsubscribe', 'Postmatic'))));
 }
Beispiel #5
0
 protected function import($subscriber)
 {
     $existing_user = get_user_by('email', $subscriber['email_address']);
     $prompt_site = new Prompt_Site();
     if ($existing_user and $prompt_site->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if ($existing_user) {
         $subscriber_id = $existing_user->ID;
     } else {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber['email_address']);
     }
     $prompt_site->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Jetpack Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
Beispiel #6
0
 /**
  * Handle unsubscribe requests from the comment form.
  */
 public static function action_wp_ajax_prompt_comment_unsubscribe()
 {
     if (!wp_verify_nonce($_POST['nonce'], self::AJAX_NONCE)) {
         wp_die(-1);
     }
     $post_id = absint($_POST['post_id']);
     if (!$post_id) {
         wp_die(0);
     }
     $current_user = Prompt_User_Handling::current_user();
     $prompt_post = new Prompt_Post($post_id);
     if (!$current_user or !$prompt_post->is_subscribed($current_user->ID)) {
         wp_die(0);
     }
     $prompt_post->unsubscribe($current_user->ID);
     _e('You have unsubscribed.', 'Postmatic');
     wp_die();
 }