Forum Replies Created
-
In reply to: Get Post ID from Notification
I had a very strange circumstance based on a custom notifications loop where we hooked into the messaging system. I had to find my post_id from the message thread_id. Probably won’t help anyone but maybe! 😀
In reply to: Get Post ID from Notificationobject(BP_Notifications_Notification)#394 (8) { ["id"]=> string(3) "297" ["item_id"]=> string(3) "242" ["secondary_item_id"]=> string(1) "1" ["user_id"]=> string(1) "1" ["component_name"]=> string(8) "messages" ["component_action"]=> string(11) "new_message" ["date_notified"]=> string(19) "2015-07-20 20:11:46" ["is_new"]=> string(1) "0" }The actual Post ID in question is 756.
In reply to: Get Post ID from NotificationIs this what you were looking for?
object(BP_Notifications_Notification)#394 (8) { ["id"]=> string(26) "bp_get_the_notification_id" ["item_id"]=> NULL ["secondary_item_id"]=> NULL ["user_id"]=> NULL ["component_name"]=> NULL ["component_action"]=> NULL ["date_notified"]=> NULL ["is_new"]=> NULL }In reply to: Get Post ID from NotificationAfter reverting the file … it’s still just displaying the “notification id.”
In reply to: Get Post ID from NotificationAck my bad! I’m fairly new to php and super new to Buddypress.
Ok soooo … in the file notifications-loop.php inside the loop I’ve added:
$notificationid7 = bp_get_the_notification_id(); $obj = bp_notifications_get_notification( $notificationid7 );And where I need to display the link (also in notifications-loop.php):
<a href="/pins/<?php echo $obj->item_id; ?>">view</a>Lastly, where I passed the item ID in bp-notifications-functions.php:
function bp_notifications_add_notification( $args = array() ) { $r = wp_parse_args( $args, array( 'user_id' => 0, 'item_id' => $post_id, 'secondary_item_id' => 0,However it’s echoing the notification number … not the post ID.
In reply to: Get Post ID from NotificationWhat’d you do to fix your code? I’m still stuck! 😀
In reply to: Get Post ID from Notificationfunction allofdalights(){ $obj = bp_notifications_get_notification( $id ); echo $obj->item_id; }In reply to: Get Post ID from NotificationThis is my code:
<?php while ( bp_the_notifications() ) : bp_the_notification(); $user_id = $bp->notifications->query_loop->notification->secondary_item_id; //bp_notifications_mark_notification(bp_get_the_notification_id(),false); ?><?php $messageId = buddypress()->notifications->query_loop->notification->item_id; $message = messages_get_message($messageId); $image = null; if ($message) { $title = apply_filters( 'bp_get_message_thread_from', bp_core_get_userlink( $message->sender_id ) ); if ($message->subject == "comment on your post") { $title .= " commented on your post"; } elseif ($message->subject == "like your post") { $title .= " liked your post"; } else { $title = null; } $image = bp_messages_get_meta($messageId, 'images'); $obj = bp_notifications_get_notification( $id ); } ?>And the echo:
<div><a href="/pins/<?php echo $obj->item_id; ?>">VIEW</a></div>In reply to: Get Post ID from NotificationI also don’t know what to do with:
$obj = bp_notifications_get_notification( $id ); echo $obj->item_id;Do I make a function of it?
In reply to: Get Post ID from NotificationIs this the proper way to have it setup at the function?
function bp_notifications_add_notification( $args = array() ) { $r = wp_parse_args( $args, array( 'user_id' => 0, 'item_id' => $post_id, 'secondary_item_id' => ,In reply to: Get Post ID from Notification$notificationpostid = bp_notifications_get_notification(secondary_item_id);In reply to: Get Post ID from NotificationWicked awesome! Going to check it out now.
In reply to: Get Post ID from NotificationDidn’t mean to post this.
In reply to: Get Post ID from NotificationCan I simply add post_id into this?
function bp_notifications_add_notification( $args = array() ) { $r = wp_parse_args( $args, array( 'user_id' => 0, 'item_id' => 0, 'secondary_item_id' => 0, 'component_name' => '', 'component_action' => '', 'date_notified' => bp_core_current_time(), 'is_new' => 1, 'allow_duplicate' => false, ) ); // Check for existing duplicate notifications if ( ! $r['allow_duplicate'] ) { // date_notified, allow_duplicate don't count toward // duplicate status $existing = BP_Notifications_Notification::get( array( 'user_id' => $r['user_id'], 'item_id' => $r['item_id'], 'secondary_item_id' => $r['secondary_item_id'], 'component_name' => $r['component_name'], 'component_action' => $r['component_action'], 'is_new' => $r['is_new'], ) ); if ( ! empty( $existing ) ) { return false; } } // Setup the new notification $notification = new BP_Notifications_Notification; $notification->user_id = $r['user_id']; $notification->item_id = $r['item_id']; $notification->secondary_item_id = $r['secondary_item_id']; $notification->component_name = $r['component_name']; $notification->component_action = $r['component_action']; $notification->date_notified = $r['date_notified']; $notification->is_new = $r['is_new']; // Save the new notification return $notification->save(); }In reply to: Get Post ID from NotificationWe hooked into a liking plugin and wp-comments to include notifications for activity on those two actions.
Then the notifications are coming in Ajax to a flyout window. 😀
In reply to: Get Post ID from NotificationI have tried about 100 different things and I thought this would work:
get_post_meta($post->ID,'thread_id');In reply to: Get Post ID from NotificationOr how can I add a column in the database table bp_notifications for post_id?
Thanks!
In reply to: Get Post ID from NotificationThe goal being … I want to make a clickable link in the notification to go to the post corresponding to the notification.
In reply to: Mark Particular Messages as ReadYou my friend are beautiful! 😀 😀
Worked like a charm. Thanks!
In reply to: Allow Empty “What’s New” Activity UpdateTrying to clean up the mess that the other developer created basically. We came up with a different solution.
Basically we changed What’s New to “About Me” but we wanted to allow for an empty “About Me.”
We also moved the Activity Stream to a, “My Profile” page and did something very hacky by calling the Activity Stream and hiding everything except for “Delete” and naming that “Clear my About Me.”
BTW .. I am very new to development. Thanks for helping out.
In reply to: Allow Empty “What’s New” Activity UpdateAck! My bad … new to the forum!!!
add_filter('pre_post_title', 'wpse28021_mask_empty'); add_filter('pre_post_content', 'wpse28021_mask_empty'); function wpse28021_mask_empty($value) { if ( empty($value) ) { return ' '; } return $value; } add_filter('wp_insert_post_data', 'wpse28021_unmask_empty'); function wpse28021_unmask_empty($data) { if ( ' ' == $data['post_title'] ) { $data['post_title'] = ''; } if ( ' ' == $data['post_content'] ) { $data['post_content'] = ''; } return $data; }