Group Admins

  • Profile picture of Steve

BuddyPress Troubleshooting and Support

Public Group active 4 years, 7 months ago ago

BuddyPress support from our community

How to create custom activity in activity stream?

This topic contains 0 replies, has 1 voice, and was last updated by  grimmwerks 6 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1525

    grimmwerks
    Participant

    Hey all – I’m trying to find a solution on the web but have found how to show custom post types in a stream upon post save — or pre 1.5 — but I need to do something different — I’ve created a plugin that is a voting / poll plugin and need to post something like ‘Username answered the poll *whatever poll name* – but can’t really find an example of how to get that going… any help would be appreciated.

    #2650

    grimmwerks
    Participant

    Hmm –

    I’ve got a plugin that basically is a voting / poll plugin. Upon someone voting on a post I’d like to do a *user* voted on *poll name* / link to single — (it does use a custom post type but the examples that show activity based upon a post publishing aren’t valid). I’m having a bit of a brain fart trying to get this to work because the examples I see it’s not clear how to actually INITIATE said activity. i.e.:

    I set this up:

    function bp_example_record_activity( $args = ” ) {
    global $bp;

    if ( !function_exists( ‘bp_activity_add’ ) )
    return false;

    $defaults = array(
    ‘id’ => false,
    ‘user_id’ => $bp->loggedin_user->id,
    ‘action’ => ”,
    ‘content’ => ”,
    ‘primary_link’ => ”,
    ‘component’ => $bp->example->id,
    ‘type’ => false,
    ‘item_id’ => false,
    ‘secondary_item_id’ => false,
    ‘recorded_time’ => gmdate( “Y-m-d H:i:s” ),
    ‘hide_sitewide’ => false
    );

    $r = wp_parse_args( $args, $defaults );
    extract( $r );

    return bp_activity_add( array( ‘id’ => $id, ‘user_id’ => $user_id, ‘action’ => $action, ‘content’ => $content, ‘primary_link’ => $primary_link, ‘component’ => $component, ‘type’ => $type, ‘item_id’ => $item_id, ‘secondary_item_id’ => $secondary_item_id, ‘recorded_time’ => $recorded_time, ‘hide_sitewide’ => $hide_sitewide ) );
    }

    Then do I call via bp_example_record_activity( array( ‘type’ => ‘new_highfive’, ‘action’ => ‘Andy high-fived John’, ‘user_id’ => $bp->loggedin_user->id, ‘item_id’ => $bp->displayed_user->id ) );

    Thanks for any links, tutorials, info, ancient chinese secrets.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.