bp_activity_get_specific()
should be used like this:
// get activity
$activity_get = bp_activity_get_specific( array( 'activity_ids' => YOURACTIVITYID ) );
// single out the activity
$activity = $activity_get[0];
// grab specific activity item
$activity_body = $activity->content;
Ref: https://buddypress.org/support/topic/gettinng-id-of-the-activity-status/#post-112943
@henrywright I have already tried that, but it returns an empty array. As I mentioned earlier, if I supply the ID of a non-comment activity, I get results. No results with activity comments.
Still need help with this :/
I am going to open a trac ticket. I believe this is a bug.
You should state the versions of BP & WP being used.
You can always query the db directly.
In this case, probably:
global $bp, $wpdb;
$wpdb->get_var( "SELECT secondary_item_id FROM {$bp->activity->table_name} WHERE id = $comment_id ");
or maybe
global $bp, $wpdb;
$wpdb->get_var( "SELECT item_id FROM {$bp->activity->table_name} WHERE id = $comment_id ");
Arg, I always forget.
BP 2.0, WP 3.9
I am actually doing exactly that @shanebp! I also added that on the trac ticket I created
I was incorrect, it’s not a bug. The solution (thanks to @r-a-y) is this:
$act_item = bp_activity_get_specific( array(
'display_comments' => true,
'activity_ids' => ACTIVITY_COMMENT_ID
) );
Closed trac ticket can be viewed here https://buddypress.trac.wordpress.org/ticket/5592#comment:4
Nice – and obvious 🙂
Querying the db directly should be avoided if possible – [laziness and bad habit].
Yeah, I generally try to avoid it which is why I was trying so hard to find the correct solution 😀
@godavid33
10 years, 8 months ago
I have attempted to retrieve the activity object using bp_activity_get_specific() and variations thereof, with no luck. My findings are that I can infact use that function to retrieve an activity, but this activity cannot be a comment or else an empty array is returned.
What’s going on with that? That seems kind of pointless. But that aside, how can I get the parent activity ID, or more to the point, the thread link given the comment ID?