Last active
October 8, 2016 14:36
-
-
Save TiagoGouvea/4a3283eb929e1872fe86c151e3fa4c47 to your computer and use it in GitHub Desktop.
Wordpress - Subscribe to comments reloaded - Suscribe to all users (bulk, mass)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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