Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Using bp_activity_add() to update an activity (8 posts)

Started 1 year, 8 months ago by: Matthew Holt

  • Profile picture of Matthew Holt Matthew Holt said 1 year, 8 months ago:

    When using bp_activity_add() to update an activity, I am having a bit of a challenge. I have tried two approaches:
    1. create an array of the elements needed to update, with a known activity id and pass them to bp_activity_add()
    eg.

    $activity=array('id'=>533,'hide_sitewide' => true,'content'=>'test 1', 'action'=>'test test');
    do_action('bp_activity_add',$activity);

    2. Create an activity object and add assign the ID property and pass it to bp_activity_add()
    eg.

    $activity = new BP_Activity_Activity ();
    $activity->ID=533;
    $activity->hide_sitewide=true;
    $activity->content="test 1";
    $activity->action="test test";
    do_action('bp_activity_add',$activity);

    What am I missing? Is there a different way to do this?

    Please advise.

  • Profile picture of rich! @ etiviti rich! @ etiviti said 1 year, 8 months ago:

    something like:

    $activity_id = bp_activity_add( array( 'id' => 555, 'action' => 'something new and blue' );

    no reason to use the do_action – that is just a trigger point for hooking into buddypress.

    make sure you capture all the previous activity data and pass that back in – performs a full sql update on all cols (see the code in http://wordpress.org/extend/plugins/buddypress-edit-activity-stream/ )

  • Profile picture of Matthew Holt Matthew Holt said 1 year, 8 months ago:

    Odd, no luck. Data is not changed, and nothing is returned in $activity_id. Any thoughts?

    @nuprn1 are you saying that I need to capture all the activity data and pass it back to the bp_activity_add() in order for the update to be executed?

  • Profile picture of r-a-y r-a-y said 1 year, 8 months ago:

    Change “action” to “content” in Rich’s code.

  • Profile picture of Matthew Holt Matthew Holt said 1 year, 8 months ago:

    I actually did that as well and had the same result :( .
    $activity_id = bp_activity_add( array( 'id' => 468, 'content' => 'something new and blue' ));

    You would think one of these would work.

  • Profile picture of Matthew Holt Matthew Holt said 1 year, 8 months ago:

    I have tried attempting this from a couple different pages. Originally from post-form.php and also from the main activity loop with no luck. It doesn’t appear that I’m doing anything special?

  • Profile picture of nicholmikey nicholmikey said 11 months, 3 weeks ago:

    Did anyone get a solution to this? I have tried several methods of adding activities to the stream with no luck.

  • Profile picture of nicholmikey nicholmikey said 11 months, 3 weeks ago:

    So far I have tracked the problem to bp-activity-classes, in the save() function, for some reason {$bp->activity->table_name} is returning nothing so the SQL structure ends up missing a table name. Makes no sense as other plugins like bbpress uses this save() feature and works fine.