Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm looking to build out the following functionality, but I'm having trouble finding any help on it:

user follows a post > user's email is pulled into an admin page and associated with said post > admin can then email all users who have followed a single post, updating them when a significant change has been made

I'd appreciate any insights you have!

share|improve this question

2 Answers 2

I don't think its polite to send email to all users who Favorited your post. Because some people favorite your post to bookmark it. So don't combine favorite with follow.

So here is my suggestion:

For bookmarking, use WP favorite posts plugin.

As for the follow there is no plugin exists for normal wordpress installation. However there is a plugin available for buddypress. Its called buddypress follow me.

You need to replace buddypress functions with default wordpress functions.

For example, this line uses the function bp_loggedin_user_id(). You need to replace it with get_current_user_id()

If you don't have experience in wordpress, then hire an experienced programmer. He/she can finish it within 1 hour.

I think modifying buddypress plugin is better than coding everything from scratch.

All the best

Update

If you are going to code it from scratch, here is some code

function wpse_follow() {
    if(!is_user_logged_in()) {
    return false;
    }
    global $post;
    $current_user = get_current_user_id();
    $followers = get_post_meta($post->ID, 'followers');
    if(!$followers) {
    $first_follower = array($current_user);
    update_post_meta($post->ID, 'followers', $first_follower);
    } else {
    $pushed_array = array_push($followers, $current_user);
    update_post_meta($post->ID, 'followers', $pushed_array);
    }
}

Later you can get the followers array by using this code.

global $post;
$followers = get_post_meta($post->ID, 'followers');

Lets retrieve emails of subscribed users.

$user_emails = array();
foreach ($followers as $follower) {
    $email = get_user_by('id', $follower);
    $user_emails[] = $email;
} 
share|improve this answer
    
Thanks for the answer! I'll check out the BuddyPress thing. As for the functionality, this is an internal tool for my company, where my coworkers can "opt-in" to get email updates on a specific post. I'm not trying to spam anyone :) –  Erica Decker Mar 21 '13 at 18:23
    
BuddyPress Follow Me won't work after all. I need users to be able to follow a post, not an author. –  Erica Decker Mar 21 '13 at 18:48
    
@EricaDecker Yes it will work. You have to modify it little bit. For example profile page uses author id. You should replace it with post id. Anyway I updated my answer with some code. Check it. Hope that helps –  Giri Mar 21 '13 at 19:22

Thanks for the answers, people! I got this up and running by leveraging the work already done by http://wordpress.org/extend/plugins/wp-favorite-posts/ and http://yoast.com/wordpress/email-commenters/.

I edited WP Favorite Posts to create a new DB table and add user emails to an array every time they favorited a post, and then remove the email if they unfavorite. I then rewrote Email Commenters to use the new string of emails associated with WPFP, rather than the commenters.

The result is pretty simple, where an admin can click the mail link, and open a mailto to the appropriate users to let them know of important changes.

share|improve this answer
    
+1 Very nice posting your solution! Note that in the Stack, we thank people up voting their good answers, check: How does accepting an answer work? :) –  brasofilo Apr 3 '13 at 18:59
    
Would you consider adding this as a new plugin to the repo so others may profit? –  JimmyPena Apr 3 '13 at 19:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.