Skip to:

Hook on New Topic or Reply

  • rsmithgs


    WordPress Version: 5.2.2
    BuddyPress Version: 4.4.0
    bbPress Version: 2.5.14

    Hello, I’m looking for a hook to grab data of new topics and replies as they are added.

    I was thinking this would do the trick, but it does not trigger my curl request.

    add_action('groups_forum_new_topic_after', 'group_was_posted_on', 10, 2);
    add_action('groups_forum_new_reply_after', 'group_was_posted_on', 10, 2);

    Then I tried this:

    //new topic was created
    add_action('bp_forums_new_topic', 'group_was_posted_on', 10, 2);
    //new post was created to a topic
    add_action('bp_forums_new_post', 'group_was_posted_on', 10, 2);

    Still no luck. What actions/hooks do I need to use for:
    User creates a new topic
    User creates a new reply to a topic

    Thanks for your help

Viewing 1 replies (of 1 total)

  • rsmithgs


    Hello guys,

    Just in case anyone else was wondering. If you want to grab data from topics or replies you need to grab the hook that fires after it is saved. These 2 did the trick:

    //for when new topic was created
    add_action('bbp_new_topic_post_extras', 'group_has_new_topic', 10, 2);
    //for when new reply was created to a topic
    add_action('bbp_new_reply_post_extras', 'group_topic_has_new_reply', 10, 2);

    I know that this will grab all bbPress topics and replies, but it fits my purposes.
    If anyone knows how to grab only BuddyPress Group Forums’ Topics and Replies that would be awesome, but for now this will work for me and I hope it works for others!

    These actions rely on $topic_id and $reply_id only and respectfully, but you can grab any other data such as Topic Title, Forum Name, Topic or Reply Author, etc. through the Topic or Reply ID alone like so:

    $topic_id = bbp_get_reply_topic_id($reply_id);
        $topic_title = bbp_get_topic_title($topic_id);
        $forum_id = bbp_get_topic_forum_id($topic_id);
        $forum_title = bbp_get_forum_title($forum_id);
        $user = bbp_get_reply_author_id($reply_id);
        $user_info = get_userdata($user);
        $username = $user_info->user_login;
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar