Skip to:
Content
Pages
Categories
Search
Top
Bottom

Email Group Email subscription & adding blog posts to activity feed


  • becskr
    Participant

    @becskr

    We have a sitewide wp blog which has a category that matches a bp group name. I want to be able to send an email out to everyone registered in the group matching that category plus another category. E.g. It is category and is category “new event”.

    We’re already using bp group email subscription so I think the best way would be to add the blog post into the group activity feed and mark it as important so it is sent to everyone who is subscribed to the group. I’m really struggling how to do this, would anyone be able to help me?

Viewing 13 replies - 1 through 13 (of 13 total)

  • becskr
    Participant

    @becskr

    bump


    Boone Gorges
    Keymaster

    @boonebgorges

    Here’s what I suggest.

    Copy the function `bp_blogs_record_post()` to your own plugin, and rename it. Near the beginning of the function, add a little logic that does the following:
    – Gets the post categories, based on` $post_id`
    – Based on the post categories, looks up the group(s) in which the post should appear

    With this additional information, do the following. I’m assuming here that you just have a single group as the result of the above logic, but if you have more than one, you’ll need to loop over them.
    – Change the call to `bp_blogs_record_activity()` to `groups_record_activity()`
    – Change the `hide_sitewide` value to `false`, so that you don’t get duplicates
    – Change the `item_id` to the group id

    That should make these posts show up in the group activity stream.

    To make sure they get sent to everyone, even if they are subscribed to Weekly Digests or New Topics Only, drop a line in your function above:

    `add_filter( ‘ass_this_activity_is_important’, ‘__return_true’ );`


    becskr
    Participant

    @becskr

    Hi Boon, I’ve got as far as I can and now stuck. Just wondered if you could help me out a bit more?
    The post is in two categories – one will always be “new-events” and the other will have a slug that matches the group name.

    Could you have a look over my code and see what I’m doing wrong?

    http://pastebin.com/QnniULau


    Boone Gorges
    Keymaster

    @boonebgorges

    Can you clarify what you’re trying to do, and the ways in which what you’ve written are falling short? I take it that the “two categories” is *not* what you want?


    becskr
    Participant

    @becskr

    OK, so what I want to do is add the activity to the feed when the category for the post matches the slug for a group. The problem is it isn’t at the moment. It’s not doing anything.

    Code is saying “get the ID of the new-events category and if the other category assigned to that post does not match that ID then get the group ID for the group slug that matches the category slug. Then add the activity to that group.”


    Boone Gorges
    Keymaster

    @boonebgorges

    Have you tried doing some logging/dumping to see where things are going awry? What happens when you dump the following:

    `var_dump( $post_categories );
    var_dump( $new_events_slug );
    var_dump( $cat );
    `

    after each one of them is defined? That’ll tell you in a hurry where things are getting messed up.

    At a glance, I’m guessing that the failure is here:

    `$cat = get_category( $c );
    if(!$cat==$new_events_slug){`

    because I don’t think that `get_category()` returns a slug ( I think it returns a category object). But var_dump() or print_r() will tell you where you’re going wrong.


    becskr
    Participant

    @becskr

    Hi Boone,

    Right thanks for the var dunp stuff, that’s got the first bit working and the correct info is stored in the variables.
    I’m having some trouble now with the actual function itself. I changed the function name and changed the `item id` value to $groupid but nothing happens. I took the blog_record_activity from the core files and changed to groups_record_activity but am wondering whether it’s the component bit that’s the issue? I noticed in this post: https://wordpress.org/support/topic/plugin-buddypress-groupblog-adding-an-entry-to-group-activity-stream that the component is set to “groups” .

    Progress so far: http://pastebin.com/LTWSDM2i


    becskr
    Participant

    @becskr

    I’ve sorted it! I did need to put the component as groups :)


    MatthewByrom
    Participant

    @matthewbyrom

    Hi There @becskr,

    We have a similar problem on a website that has blog posts & we would like the blog posts added to the group activity feed, so people can receive an email digest, but we are at a loss as to when to call the function etc.

    Can you recall how/where to declare this function? Any advice appreciated.

    Thanks.


    becskr
    Participant

    @becskr

    Yes sure, helping you with this.


    becskr
    Participant

    @becskr

    OK so I have posted this in another thread but I’m going to post it here in case anyone else wants to use it. I created a plugin that will take a blog post category slug and where the group slug matches it exactly, it will post the activity to that group’s feed and send an email notification using the Group Email Subscription.

    Here’s the link to the pastebin with the plugin: http://pastebin.com/R5U6TLG7


    Gintas
    Participant

    @gintautas84

    Thanks for great plugin! How about adding comments of post to related group activity stream?


    becskr
    Participant

    @becskr

    Sorry but I haven’t got time to look at this at the moment and wasn’t planning on maintaining it. I’m not really a developer!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Email Group Email subscription & adding blog posts to activity feed’ is closed to new replies.
Skip to toolbar