I swear, probably 80% of my posts result in me solving my own damn problem.
Inside your notification loop, if you can not see the item_id when using print_r on the notification object (returned by bp_core_get_notifications_for_user($uid, ‘object’) ) then call this function on the notification ID: bp_notifications_get_notification( $notif->id )
The object this returns contains the item_id (print_r it to see what’s up).
Hope this helps someone
Hi @godavid33
I’m 99% sure you can. I do believe it’s store in secondary_item_id
.
I think you can access it by doing something like this:
$notifications = BP_Notifications_Notification::get( array(
'id' => $notification_id,
'user_id' => $user_id
) );
// I assume there will only be one result but i'll do a loop anyway
if ( $notifications ) {
foreach( $notifications as $notification ) {
// this should output the friendship ID
echo $notification->secondary_item_id;
}
}
Oops, didn’t see your second post. Glad you solved the problem!
@godavid33
Did you try:
bp_get_the_notification_item_id()
from
\buddypress\bp-notifications\bp-notifications-template.php
No @shanebp I didn’t try that, though I probably will. I don’t see why it would be any different than my soluton though.
I am now presented with the problem of getting the parent activity id of a comment though, if y’all know how to solve that 😛
**EDIT: I tried your method Shane, but it didn’t work since I am not instantiating a loop, but a using an informal foreach and thus need to be able to pass the id of the notif**