Skip to content

Instantly share code, notes, and snippets.

@TiagoGouvea
Last active October 8, 2016 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TiagoGouvea/4a3283eb929e1872fe86c151e3fa4c47 to your computer and use it in GitHub Desktop.
Save TiagoGouvea/4a3283eb929e1872fe86c151e3fa4c47 to your computer and use it in GitHub Desktop.
Wordpress - Subscribe to comments reloaded - Suscribe to all users (bulk, mass)
global $wp_subscribe_reloaded;
echo "Subscribe old comments<br><br>";
// Get all comments on database
$comments = get_comments(array('type'=>'comment'));
$added=0;
echo "Comments: ".var_dump(count($comments))."<br>";
foreach ($comments as $comment){
$postId=$comment->comment_post_ID;
$email=$comment->comment_author_email;
if (strpos(email,'YOUR_EMAIL')!==false) continue;
$subscribed = $wp_subscribe_reloaded->stcr->is_user_subscribed($postId,$email);
if ($subscribed==false) {
$wp_subscribe_reloaded->stcr->add_subscription($postId, $email, 'Y');
$added++;
}
}
echo "$added subscribers added!<br>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment