BuddyBoss Home – Web › Support Forums › Plugins › BuddyBoss Wall › buddyboss Wall and mentions notification
- This topic has 9 replies, 2 contibutors, and was last updated 10 years, 2 months ago by Jap.
-
Question
September 23, 2014 at 2:28 am #31927@danpajoHello,
I am using buddyboss wall and it is looking great.
I found out one problem. Without the wall when i mention a user the user will get a notification in the adminbar. After opening the notifications and clicking on the mention notification the user is directed to his/her mentions tab. The mentions notification is deleted/marked as read.
When I activate Buddyboss Wall and i mention a user there is something going wrong. The mention is appearing in the admin bar notifications. Now it is not directing to the /mentions/ tab anymore but it’s directing to http://danpajo.com/members/Danpajo/activity/.
The mention is showing up overthere but the notification is not marked as read or deleted.
The user can only remove it manually.
Can you please give me an advice how to solve this? Because not removing the notifications anymore is annoying.
thank you in advantage
Jap
Answers
September 23, 2014 at 2:40 am #31928@danpajoI checked my email notifications and the link in the email is directing me to the right place. When i click that link I go direct to the notification and its deleted / marked as read in my notification tab.
The output of the mail is:
japtest mentioned you in an update: "@Danpajo danpajo is gek" To view and respond to the message, log in and visit: http://danpajo.com/activity/477/
The notification link is referring to: http://danpajo.com/members/Danpajo/activity/
How can i change that!!
September 23, 2014 at 3:11 am #31929@danpajoOk in bp-activity-notifications.php in the Buddypress/bp-activity folder its saying this about the mentions:
from line 252:
/** Notifications *************************************************************/ /** * Format notifications related to activity. * * @since BuddyPress (1.5) * * @uses bp_loggedin_user_domain() * @uses bp_get_activity_slug() * @uses bp_core_get_user_displayname() * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook. * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook. * @uses do_action() To call 'activity_format_notifications' hook. * * @param string $action The type of activity item. Just 'new_at_mention' for now. * @param int $item_id The activity ID. * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID. * @param int $total_items The total number of notifications to format. * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise. * @return string $return Formatted @mention notification. */ function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { switch ( $action ) { case 'new_at_mention': $activity_id = $item_id; $poster_user_id = $secondary_item_id; $at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/'; $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() ); if ( (int) $total_items > 1 ) { $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items ); $filter = 'bp_activity_multiple_at_mentions_notification'; } else { $user_fullname = bp_core_get_user_displayname( $poster_user_id ); $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname ); $filter = 'bp_activity_single_at_mentions_notification'; } break; } if ( 'string' == $format ) { $return = apply_filters( $filter, '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id ); } else { $return = apply_filters( $filter, array( 'text' => $text, 'link' => $at_mention_link ), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id ); } do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); return $return; } /** * Notify a member when their nicename is mentioned in an activity stream item. * * Hooked to the 'bp_activity_sent_mention_email' action, we piggy back off the * existing email code for now, since it does the heavy lifting for us. In the * future when we separate emails from Notifications, this will need its own * 'bp_activity_at_name_send_emails' equivalent helper function. * * @since BuddyPress (1.9.0) * * @param obj $activity * @param string $subject (not used) * @param string $message (not used) * @param string $content (not used) * @param int $receiver_user_id */ function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) { if ( bp_is_active( 'notifications' ) ) { bp_notifications_add_notification( array( 'user_id' => $receiver_user_id, 'item_id' => $activity->id, 'secondary_item_id' => $activity->user_id, 'component_name' => buddypress()->activity->id, 'component_action' => 'new_at_mention', 'date_notified' => bp_core_current_time(), 'is_new' => 1, ) ); } } add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notification', 10, 5 ); /** * Mark at-mention notifications as read when users visit their Mentions page. * * @since BuddyPress (1.5) * * @uses bp_notifications_mark_all_notifications_by_type() */ function bp_activity_remove_screen_notifications() { if ( ! bp_is_active( 'notifications' ) ) { return; } // Only mark read if you're looking at your own mentions if ( ! bp_is_my_profile() ) { return; } bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' ); } add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' ); /** * Mark at-mention notification as read when user visits the activity with the mention. * * @since BuddyPress (2.0.0) */ function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) { if ( ! bp_is_active( 'notifications' ) ) { return; } if ( ! is_user_logged_in() ) { return; } // Mark as read any notifications for the current user related to this // activity item bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' ); } add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' ); /** * Delete at-mention notifications when the corresponding activity item is deleted. * * @since BuddyPress (2.0.0) * * @param array $activity_ids_deleted IDs of deleted activity items. */ function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) { // Let's delete all without checking if content contains any mentions // to avoid a query to get the activity if ( bp_is_active( 'notifications' ) && ! empty( $activity_ids_deleted ) ) { foreach ( $activity_ids_deleted as $activity_id ) { bp_notifications_delete_all_notifications_by_type( $activity_id, buddypress()->activity->id ); } } } add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_notification', 10 );
You see the reffering to /mentions/
In the email part it is coded different:
From line 13:
/* Emails *********************************************************************/ /** * Send email and BP notifications when a user is mentioned in an update. * * @since BuddyPress (1.2) * * @uses bp_notifications_add_notification() * @uses bp_get_user_meta() * @uses bp_core_get_user_displayname() * @uses bp_activity_get_permalink() * @uses bp_core_get_user_domain() * @uses bp_get_settings_slug() * @uses bp_activity_filter_kses() * @uses bp_core_get_core_userdata() * @uses wp_specialchars_decode() * @uses get_blog_option() * @uses bp_is_active() * @uses bp_is_group() * @uses bp_get_current_group_name() * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook. * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook. * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook. * @uses wp_mail() * @uses do_action() To call the 'bp_activity_sent_mention_email' hook * * @param int $activity_id The ID of the activity update. * @param int $receiver_user_id The ID of the user who is receiving the update. */ function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) { // Don't leave multiple notifications for the same activity item $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' ); foreach( $notifications as $notification ) { if ( $activity_id == $notification->item_id ) { return; } } $activity = new BP_Activity_Activity( $activity_id ); $subject = ''; $message = ''; $content = ''; // Now email the user with the contents of the message (if they have enabled email notifications) if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { $poster_name = bp_core_get_user_displayname( $activity->user_id ); $message_link = bp_activity_get_permalink( $activity_id ); $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; $settings_link = bp_core_get_user_domain( $receiver_user_id ) . $settings_slug . '/notifications/'; $poster_name = stripslashes( $poster_name ); $content = bp_activity_filter_kses( strip_tags( stripslashes( $activity->content ) ) ); // Set up and send the message $ud = bp_core_get_core_userdata( $receiver_user_id ); $to = $ud->user_email; $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ) ) ); if ( bp_is_active( 'groups' ) && bp_is_group() ) { $message = sprintf( __( '%1$s mentioned you in the group "%2$s": "%3$s" To view and respond to the message, log in and visit: %4$s --------------------- ', 'buddypress' ), $poster_name, bp_get_current_group_name(), $content, $message_link ); } else { $message = sprintf( __( '%1$s mentioned you in an update: "%2$s" To view and respond to the message, log in and visit: %3$s --------------------- ', 'buddypress' ), $poster_name, $content, $message_link ); } // Only show the disable notifications line if the settings component is enabled if ( bp_is_active( 'settings' ) ) { $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); } // Send the message $to = apply_filters( 'bp_activity_at_message_notification_to', $to ); $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name ); $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link ); wp_mail( $to, $subject, $message ); } do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id ); }
I want the email link and the notification link work the same so the notifications will get marked read after clicking the notification.
I hope you can help me out!!
jap
September 23, 2014 at 3:24 am #31930@danpajoI also found the same lines of php in wall-hooks.php of buddyboss
line 395:
/** * Format @mention notifications to redirect to the wall * @param [type] $notification [description] * @return [type] [description] */ function buddyboss_wall_format_mention_notification( $notification, $at_mention_link, $total_items, $activity_id, $poster_user_id ) { global $wp_admin_bar, $bp; $domain = $bp->loggedin_user->domain; $activity_link = trailingslashit( $domain . $bp->activity->slug ); $at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/'; $at_mention_title = sprintf( __( '@%s Mentions', 'buddyboss-wall' ), bp_get_loggedin_user_username() ); if ( (int) $total_items > 1 ) { $text = sprintf( __( 'You have %1$d new mentions', 'buddyboss-wall' ), (int) $total_items ); } else { $user_fullname = bp_core_get_user_displayname( $poster_user_id ); $text = sprintf( __( '%1$s mentioned you', 'buddyboss-wall' ), $user_fullname ); } if ( is_array( $notification ) ) { $notification['link'] = $activity_link; } else { $notification = '<a href="' . $activity_link . '" title="' . $at_mention_title . '">' . $text . '</a>'; } return $notification; }
What to change so it is going straight to the mention and deletes the notifications?
September 23, 2014 at 4:24 pm #31941September 23, 2014 at 4:29 pm #31942@alyssa-buddyboss
AlyssaParticipant@danpajo try adding this to your child theme functions.php file:
remove_filter( 'bp_activity_multiple_at_mentions_notification', 'buddyboss_wall_format_mention_notification', 10, 5 ); remove_filter( 'bp_activity_single_at_mentions_notification', 'buddyboss_wall_format_mention_notification', 10, 5 );
September 24, 2014 at 3:40 am #31953@danpajoHello thank you for your input.
I made some pictures because it did not work out.
Picture 1 – functions.php
I putted it in my functions. There is no } needed at the end? If so it is giving me a white screen.
Picture 2: I have a Mention:
A mention is showing up in the upper right corner on the Admin Bar.
Picture 3: Hovering the mention!
As you can see the notification is pointing out to http://danpajo.com/members/Danpajo/activity
When I click on the mention it is going to http://danpajo.com/members/Danpajo without the activity slug.
Picture 4: Whats appening after clicking the mention notification
You see the url is http://danpajo.com/members/Danpajo
You see there is still a notification in the upper right corner of my site.
I have to scroll down for the first Mention it is not going automaticly to there.
But i am on my personal wall. The notification stays where he is. I think its better to go to the mention because when you have a lot of users you want to see who and where someone is mentioning you.
In my setup I had a lot of problems with the notifications. It was reffering to a url with the at the end /activity/p/(and a number). The /p/ part does not excist on my site so i Removed it from the php files.
Picture 5: I go to the same mention in Email:
As you van see in the mail it is producing a link like: http://danpajo.com/activity/499/
In this case there is no member/Danpajo part in it. So i won’t go to my wall. (why is that?)
After clicking the link you see the adress is forwarding me to the desired page on the website.
Notification counter is going down to 0.
But I arrived on a Activity page and not on my wall. Bit strange but it is working more or less.
It is not an activity page with widgets like on my personal wall but I can change that I guess.
At the end it is showing a post made on my wall. So it is reffering to the wall.
Via Email the site is doing what expected exept not forwarding to my wall.
Picture 6: When I manually change URL in Address bar:
When I make a new mention to this account I went to my email, and looked for the number behind /activity/ . Then I put http://www.danpajo.com/members/Danpajo/activity/499 and hit enter.
It went to the mention. Again on a sort of activity page. The counter went to 0 so that was good. And i came in my wall enviroment what you can see in the left sidebar. It’s showing the friends widget again.
What I need/want?
If the mentions part is working like how the email works, like sending me to http://www.danpajo.com/activity/(activity number) and the counter is going down then it is working. (at minimum)
Better would be producing an url in the email and in the notification menu in the admin bar pointing out to: http://www.danpajo.com/members/Danpajo/activity/(activity number) Then people are in their profile enviroment more or less.
Best would be after clicking the mention notification to get pointed out on the wall and the needed mention and the counter is going down after clicking.
I hope you can point me out the right directions. The whole notification and live notification took me weeks to get it working. This is the last difficulty.
regards
jap
September 24, 2014 at 3:43 am #31954@danpajops
I did copy the functions as you asked at the end of my functions.php in my childthemeSeptember 24, 2014 at 9:15 am #31956@alyssa-buddyboss
AlyssaParticipant@danpajo my code was wrong, I corrected it. Please remove the previous code and try with the edited code in my last post.
September 24, 2014 at 9:37 am #31963@danpajoYes working now like a charm…
To bad you are from the buddyboss wall.. I have got another issue… up to the next forum.
Thank you very mucht for your input.
Jap
- The question ‘buddyboss Wall and mentions notification’ is closed to new replies.