And like most cases I figured it out after posting the question
public function should_send_mention_notificaton($value, $usernames, $user_id, $activity)
{
// Return false if activity author is blocked by user_id
global $wpdb;
$id_maybe_blocked = $activity->user_id;
$blocked_ids = $wpdb->get_col( "SELECT target_id FROM {$wpdb->base_prefix}bp_block_member WHERE user_id = '$user_id' ");
if (in_array($id_maybe_blocked, $blocked_ids) == true)
return false;
return true;
}
add_filter( 'bp_activity_at_name_do_notifications', 'should_send_mention_notificaton', 1, 4);
Hi, community I need your help.
I’m using BuddyPress + WordPress multisite.
The current situation is this:
When a user is invited to join a blog he gets an email via wp_mail. He/she don’t get any notification via BuddyPress about that.
I want to also add the mail which WP send to user to the BuddyPress as BP_message so the user can accept the blog invite from his/her BP inbox.
Do you have any ideas?
Thanks in advance
Lena
Hello! How I can add a notifications like in admin bar to my site menu. (I don’t use buddypress user widget and users don’t have access to the admin panel. My site menu use like user admin panel).
Untested, but try:
function custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
// New custom notifications
if ( 'custom_action' === $action ) {
$custom_title = "You have new custom notification";
$custom_link = get_permalink( $item_id );
$custom_text = "You have a new custom notification";
// WordPress Toolbar
if ( 'string' === $format ) {
$return = apply_filters( 'custom_filter', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link );
// Deprecated BuddyBar
} else {
$return = apply_filters( 'custom_filter', array(
'text' => $custom_text,
'link' => $custom_link
), $custom_link, (int) $total_items, $item_id, $secondary_item_id );
}
return $return;
}
}
add_filter( 'bp_notifications_get_notifications_for_user', 'custom_format_buddypress_notifications', 20, 5 );
I need some custom notifications in my website. I have my code bellow, all work correctly, notification is added into database and displayed at the recipient, but without notification text
How i can fix this?
Thank you
function custom_filter_notifications_get_registered_components( $component_names = array() ) {
// Force $component_names to be an array
if ( ! is_array( $component_names ) ) {
$component_names = array();
}
// Add 'custom' component to registered components array
array_push( $component_names, 'custom' );
// Return component's with 'custom' appended
return $component_names;
}
add_filter( 'bp_notifications_get_registered_components', 'custom_filter_notifications_get_registered_components' );
function custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
// New custom notifications
if ( 'custom_action' === $action ) {
$custom_title = "You have new notification";
$custom_link = "domain.com";
$custom_text = "You have new notification";
// WordPress Toolbar
if ( 'string' === $format ) {
$return = apply_filters( 'custom_filter', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link );
// Deprecated BuddyBar
} else {
$return = apply_filters( 'custom_filter', array(
'text' => $custom_text,
'link' => $custom_link
), $custom_link, (int) $total_items, $custom_text, $custom_title );
}
return $return;
}
}
add_filter( 'bp_notifications_get_notifications_for_user', 'custom_format_buddypress_notifications', 10, 5 );
function bp_custom_add_notification( $receiver_user_id, $initiator ) {
//$post = get_post( $comment_object->comment_post_ID );
//$author_id = $post->post_author;
bp_notifications_add_notification( array(
'user_id' => $receiver_user_id,
'item_id' => $initiator,
'secondary_item_id' => $initiator,
'component_name' => 'custom',
'component_action' => 'custom_action',
'date_notified' => bp_core_current_time(),
'is_new' => 1,
) );
}
add_action( 'wp_insert_custom_notification', 'bp_custom_add_notification', 99, 2 );
Hi there,
I was trouble shooting already hosted live website which is already setup buddy press wall.
BuddyPress – Version 4.1.0
BuddyBoss Wall – Version 1.3.2
BuddyBoss Media – Version 3.2.2
BuddyPress Activity Filter – Version 2.0.0
Wordpress – Version 4.9.6
And user can post on there friend profile and see the posted on user wall. But when mentioned user wall doesn’t display it. Any idea what will causing this issue.
But the wall post will notify and notification will be redirect site-wide-activity page display posts on that page, not on their wall.
Ah yes, slight correction required:
<?php $args = array(
'links' => array(
bp_get_the_notification_mark_link( bp_displayed_user_id() )
)
);?>
thanks for your help, I have got the page to only show the unread link but now when you hover over the link, it wont work as the format of the link is wrong, do you know why?
This is the link before (top) and after (bottom)
https://www.dropbox.com/s/zoiencz9qbweanr/links%20before%20and%20after%20change.jpg?dl=0
and this is my code
<?php $args = array(
'links' => array(
bp_get_the_notification_mark_link( $user_id )
)
);?>
<td class="notification-actions"><?php bp_the_notification_action_links( $args ); ?></td>
You are welcome.
When you get to edit the file you will see something like this:
<?php bp_the_notification_action_links(); ?>
The extra code will need to go within a set of PHP tags just like the function call is.
So your code should end up looking something like this:
<?php $args = array(
'links' => array(
bp_get_the_notification_mark_link( $user_id )
)
);?>
place this in a new line before the modified function call:
<?php bp_the_notification_action_links( $args ); ?>
It looks like the function bp_the_notification_action_links()
accepts $args that would allow you to remove the delete link. So you could overload your `members/single/notifications/notifications-loop.php file to include something like the following:
$args = array(
'links' => array(
bp_get_the_notification_mark_link( $user_id )
)
);
and add this to the function call: bp_the_notification_links( $args )
Something like that looks like it would work, not tested it though.
I’m trying to create a theme with a messages notification/box in the header. So far, everything works fine for regular users. However, if logged in as an administrator, bp_has_message_threads() will return nothing, even if the user has messages. This only happens on non-profile pages – if you navigate to a user profile (buddypress page), the message appear as expected. My best guess is the profile pages are executing some function that I’m not? Here’s the loop I created:
if(bp_has_message_threads(array('max' => 5)))
{
// TODO: put buttons 'mark all as read' and 'go to inbox'
while(bp_message_threads())
{
bp_message_thread();
printf('<div class="dropdown-divider"></div>');
printf('<a href="%1$s" class="dropdown-item">%2$s...<br>From: %3$s</a>',
bp_get_message_thread_view_link(),
bp_get_message_thread_excerpt(),
wp_strip_all_tags(bp_get_message_thread_from()));
}
printf('<div class="dropdown-divider"></div>');
printf('<a href="%1$smessages" class="dropdown-item">See all messages...</a>', bp_loggedin_user_domain());
}
else
{
// If users has no unread messages, tell them and give a link to their full inbox
printf('<a href="%1$smessages" class="dropdown-item">You have no messages</a>', bp_loggedin_user_domain());
}
Hi
I’m using BuddyPress and upon registration of users, the email notifications are sent using the hosting server which lands 100% of the times at spam folder.
to solve this I’ve installed the WP Mail SMTP plugin but this it didn’t affect BuddyPress Smtp settings.
Please someone with a solution to solve this.
Thanks
I am attempting to integrate BuddyPress into a custom plugin.
I would like to take certain BuddyPress sections (like Messages and Notifications) and give access to those forms so that a logged in user can compose messages, read/delete notifications, on my custom pages – not using the default BuddyPress pages (/messages/, /notifications/, etc), but using my custom pages.
What’s the best way of approaching this? I’ve looked at endpoints, shortcodes, and Buddyforms but I’m not having much luck yet.
Users names do not appear when letters are typed after @
The mention “works” notification wise but the autosuggest (I guess this is what it’s called) doesn’t.
Looking in Chrome Console I have an error:
Uncaught SyntaxError: Invalid or unexpected token mentions.min.js?ver=4.1.0:13
/wp-content/plugins/buddypress/bp-activity/js/mentions.min.js?ver=4.1.0
The error icon is shown at the end of line 13:
11 var i={
12 delay:200,hideWithoutSuffix:!0,insertTpl:”@${
13 ID
14 }
The console also says that (no error icon there though):
JQMIGRATE: Migrate is installed, version 1.4.1 jquery-migrate.min.js?ver=1.4.1:2
/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1
@datenfresser You can find them inside user meta
http://prntscr.com/m7gdur
To set default values you can check previous thread
Email notification default settings
One aspect I forgot was if the user is not logged in, ths would fix that:
const notificationsCounter = document.getElementById('ab-pending-notifications');
const notificationsIndicator = document.getElementById('wp-admin-bar-bp-notifications');
function counterChange() {
if (notificationsCounter.innerText == '0') {
notificationsIndicator.style.display = 'none';
} else {
notificationsIndicator.style.display = 'block';
}
}
if (notificationCounter){
notificationsCounter.addEventListener('change', counterChange);
}
counterChange();
Is there a function to branch pages?
Currently I am supplementing that function with the following code.
$arr = explode( '/', $_SERVER['REQUEST_URI'] );
if ( isset($arr[1]) && $arr[1] === 'members' ) :
if( is_user_logged_in() ) :
if( bp_loggedin_user_id() == bp_displayed_user_id() ) :
if( ( $arr[3] === '' || $arr[3] === 'activity' || $arr[3] === 'profile' || $arr[3] === 'following' || $arr[3] === 'followers' ) && $arr[4] != 'following' && isset($arr[3]) ) :
echo 'hello';
elseif( $arr[3] === 'forums' ) :
echo 'hello';
elseif( $arr[3] === 'bp-messages' || $arr[3] === 'settings' || $arr[3] === 'notifications' || $arr[3] === 'following' ) :
echo 'hello';
endif;
else:
if( ( $arr[3] === '' || $arr[3] === 'activity' || $arr[3] === 'profile' || $arr[3] === 'following' || $arr[3] === 'followers' ) && isset($arr[3]) ) :
echo 'hello';
elseif( $arr[3] === 'forums' && isset($arr[3]) ) :
echo 'hello';
endif;
endif;
else:
echo 'guest';
endif;
endif;
But It’s not cool..
Please inform me if you have a better method to solve the problem than the one previously mentioned.
I have real estate theme. I want web hook notifications such that when a user applies for a property on my site, notification with property details and applicant details should be sent to the owner of that property. Is it possible with buddypress notifications? And If yes, please guide me through the steps.
As you know, with Buddypress users see an email whenever someone sends them a message and they are offline. We have asked repeatedly to your support if Cometchat overrides BP’s direct messaging function at the basic pricing tier? Because Cometchat email notifications are according to your pricing menu are only available to the highest tier Enterprise pricing and that would cost $12,000 US per year! This functionality is something that Buddypress already does, free, so if CometChat ove rides this functionality then we cannot pay you $12,000 to get it back. Are we missing something? We have tried to ask your support this question but have not received a response. Thank you.
Hi there,
So i’ve managed it with a mix of my initial code which i posted firstly and your permalink, so i’ve changed basically this:
$notif = '<span class="noticecount">'. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</span>';
to this:
$notif = '<a href="' . bp_get_notifications_unread_permalink() . '"><span class="noticecount"><i class="noticecounttitle">Notifications</i>'. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</span></a>
Ok so far so good, but this alchemy failed badly with my unread messages version.
I tested bp_get_messages_permalink(), or bp_get_unread_messages_permalink()
and basically the wierdest combinations one can imagine but nothing worked.
I’ve searched then here the BP froums plus additionally stack overflow but it seems there are so many techniques to link stuff that i’m utterly lost here.
There were also permalink tags with the term slug this and slug that so i thought i ask here again before my head explodes.
Suggestion…
//notification alerts
function my_nav_menu_notif_counter( $menu, $args ) {
if (!is_user_logged_in()) {
return $menu;
} else {
if( $args->theme_location == 'primary' ) {
$unread = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
if ( 0 != $unread ) {
$link = '<a href="' . bp_get_notifications_unread_permalink() . '">Notifications '. $unread . '</a>';
$notif = '<span class="noticecount">' . $link . '</span>';
$menu .= $notif;
}
}
}
return $menu;
}
add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter', 10, 2 );
Hola, tengo el mismo el problema que @doshermanastuciudadhoy no llega el email de confirmación a los dominios hotmail…
Al eliminar el código del archivo bp-core.filters.php la web peta, tambien es cierto que yo tengo la versión 3.2.0… este es el código:
// Add 'List-Unsubscribe' header if applicable.
if ( ! empty( $tokens['unsubscribe'] ) && $tokens['unsubscribe'] !== wp_login_url() ) {
$user = get_user_by( 'email', $tokens['recipient.email'] );
$link = bp_email_get_unsubscribe_link( array(
'user_id' => $user->ID,
'notification_type' => $email->get( 'type' ),
) );
if ( ! empty( $link ) ) {
$headers['List-Unsubscribe'] = sprintf( '<%s>', esc_url_raw( $link ) );
}
}
return $headers;
}
add_filter( 'bp_email_get_headers', 'bp_email_set_default_headers', 6, 4 );
Podrías ayudarme?
Anonymous User 16484011Inactive
Hi !
Prashant,
Thanks again.
Sorry for delay in reply because I want experiments on your above article.
I read the whole third part of your above link. But it’s for making a plugin. I tried direct the changes to a demo wordpress installation php files but it’s not works for me. I mashed up because I haven’t core developer.
Can any other things or plugin solve my problem ?
I found on net about the same problem’s solution. I got the plugin pie for the same.
In this plugin I am able to add forgot password page template. Just go to pie register-> Notification -> Select tab User notification-> select template from dropdown “Password reset request”.
But after user fill password reset form when they click …
1) User got a link with token. I don’t want this ? I send just only token without link like otp.
2) After clicking user must redirect to page where they can paste the key which they received.
3) After pasting the key I have two options…
A) Either user redirect to create a new password and confirm password page.
B) OR user got a new password via mail which auto generated by site to their registered mail id.
Thanks and Regards
Hi,
I have created a custom page with a single subnav item using the code below:
function profile_tab_achievements() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Achievements',
'slug' => 'achievements',
'screen_function' => 'achievements_screen',
'position' => 100,
'parent_url' => bp_loggedin_user_domain() . '/achievements/',
'parent_slug' => $bp->profile->slug,
'default_subnav_slug' => 'awards'
) );
}
add_action( 'bp_setup_nav', 'profile_tab_achievements' );
function profile_subnav_awards() {
bp_core_new_subnav_item( array(
'name' => 'Awards',
'slug' => 'awards',
'parent_url' => bp_loggedin_user_domain() . '/achievements/',
'parent_slug' => 'achievements',
'screen_function' => 'achievements_screen'
) );
}
add_action( 'bp_setup_nav', 'profile_subnav_awards' );
I would like the subnav of this page to have a Order By Dropdown, much like exists in the groups & notification pages. I cannot find any guide on how to add this to the subnav menu though. Can anyone help? I mean just to add the drop down. I think I can probably figure out the sorting myself once I have the dropdown added.