Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'notification user id'

Viewing 25 results - 276 through 300 (of 768 total)
  • Author
    Search Results
  • #259813
    antoinegdln4
    Participant

    Hi Everyone !
    One year ago, i try to put the notifications of the Buddypress bar into my header.
    And, thanks to the members of this forum, it works succesfully.
    I have now a new item on my menu, and it’s a count of the notifications.

    But i want to see immediatly when there is a new notification !
    I would like to change the color of the notification bubble only when there is a new (ou more) notification !
    Can you help me ? :/

    There is my actual php code, on the bp-custom.php

    function my_nav_menu_notif_counter($menu) {      
            if (!is_user_logged_in())
                    return $menu;
            else
                    $notif = '<li ><a class="ab-item" href="' . bp_core_get_user_domain(bp_loggedin_user_id() ) . 'notifications/">'. __('').'<span id="ab-pending-notifications" class="pending-count alert">'. __(''). bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</span> </a></li>';
                    $menu = $menu . $notif;
                    return $menu;
    }
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter' );
    add_filter( 'show_admin_bar', '__return_false' );

    Sorry if my english is bad, i’m french
    I have bad knowledges in Php, but i can try to understand the code

    WP 4.4.5
    BP 2.6.2

    #259656
    giuseppecuttone
    Participant

    I will be your savior,
    for same rasons, wordpress decided not show admin bar like default in mobile.
    It is so,maybe, because when user log in in mobile device, a lot of menu will be showed… really I dont know why…
    But if you dont have this problem, and want show admin bar for log in an log out users, you must add in CSS the following codec:

    @media screen and (max-width:782px) {
        #wpadminbar {
            display:block;
        }
        html {
            position:absolute;
            top:-46px;
        }
    }

    The codec where say html position absolute is for delete noise black bar located in the up side zone.
    If you want, you can also show the notification icon (I think it is named budlle notification) into the admin mar, adding the following codec in CSS zone:

    /* Show only default top level items */
    	#wp-toolbar > ul > li {
        		display: block;
    	}

    I have gone mad to find the solution, but now we have it.
    If you dont want show menu in admin bar to the suscriptors, colaborator and authors, you can use the AG CUSTOM ADMIN plugin. It hide them and help you in a clean design. (you can also hide wordpress logo, and so much things…)

    Now, I have only a litlle / big problem:
    the drop down menu, when I click in the “notification icon” in the admin bar, is not showed correctly… It is showed from the “notification icon” to the right zone, so in mobiles user can red the title of the notification.
    The solution is show the dropdown menu from the “notification icon” to the left zone. So, also in mobiles users can red the title of the notification.
    Can you help me for to make that?
    I have helped you, now I hope someone can help me πŸ˜‰
    Thank for your support and have funny

    #259180
    Humiges
    Participant

    Dear @danbp
    thank you for your kind reply.
    Sorry, I’m not sure I exactly understand what do you mean.
    I definitely don’t want to complicated things (if it sounded like that)… as you said, I would like to keep the Favorite in user profile – however, I don’t need people to favorite their statuses (I actually removed that with CSS) – I wish to have it in blogs – so when for example Mike post a blog “Awesome BuddyPress πŸ˜‰ ” I can press Favorite – this means I’ld collect favorite blogs and see them in my profile anytime in the future πŸ˜‰
    This is also cool, because the notifications are there… I love this features… they are just not in the right place for me πŸ˜‰

    Thank you very much for your help πŸ™‚

    #258853
    postivamussar
    Participant

    Hi all

    Im very new to this WordPress and right now I need help with BuddyPress, since I cannot find anything comprehensible on the net.

    I am creating a dating website and what I want to do is:

    1. On the homepage, have a registration form for non users AND a log in section for members.
    See example like Facebook.com. It is important that there is space for images next to the registration form.

    2. New users can look around the site, but they cannot make contact with other members until they have validated their email account. Is it possible to show a notification/reminder on every page they visit?

    Im grateful for any help ( but please have patience with me, Im not used to computers! )

    BR, PositivaMussar

    #258804
    shekhar4431
    Participant

    I am sending to notification to multiple users with following code

     bp_notifications_add_notification( array(
    	        'user_id'           => 3,1,
    	        'item_id'           =>$postid,
    	        'component_name'    => 'Event2',
    	        'component_action'  => 'custom_action',
    	        'date_notified'     => bp_core_current_time(),
    	        'is_new'            => 1,
    	    ) );

    but notification is only send to first user id 3. How I will send the notification to multiple user id. Please help

    #258761
    tizianopitisci
    Participant

    I would like to have on my website the same solution of buddydev.com. See this examples please:

    BUDDYPRESS: https://buddypress.org/members/tizianopitisci/notifications/
    BUDDYDEV: https://buddydev.com/members/tizianopitisci/notifications/

    In buddydev users:
    1. Recive a notification by email with a link inside;
    2. Follow the link;
    3. Make the log-in;
    4. Access the private area

    I wuold like to have the same solution. Do you think is possible?

    Thanks for your help
    Tiziano

    #258729
    dsnic
    Participant

    Hi all,

    As @danbp suggested, I’ve looked at the file: bp-core/bp-core-avatars.php
    The full avatar size is indeed set to 150×150 by default there, as @imath has said.

    If the others in this thread facing the same problem are using the Kleo or Sweet Date theme, then you’ll find the default 580×580 avatar size set in this file: wp-content/plugins/bp-custom.php

    The problem, however, is that even when the image being uploaded is a lot bigger than 580×580, the error notification still appears.

    For now, I’ve temporarily “solved” the problem by commenting out the code mentioned by @danbp so the error notification doesn’t appear. This kinda works because the site will still accept the uploaded photo despite the error notification. At least this way there’s no error notification to confuse users.

    However, this is probably not the correct way to solve this issue. Can someone please help with a more elegant solution?

    Antonio
    Participant

    I created many custom notifications on my theme, such as notification on post comments, but after a post is commented and the notification is sent, the listing of posts and of other custom post types display a 404 page.

    This happens only on the listing page of posts, not on the single post pages.

    I really hope in an help.

    This is my code:

    add_action( 'bp_setup_globals', 'my_app_register_blog_notification' );
    
    /**
    * Register component
    */
    function my_app_register_blog_notification() {
    	// Register component manually into buddypress() singleton
    	buddypress()->my_app_blog = new stdClass;
    	// Add notification callback function
    	buddypress()->my_app_blog->notification_callback = 'my_app_blog_format_notifications';
    
    	// Now register components into active components array
    	buddypress()->active_components['my_app_blog'] = 1;
    }
    
    	
    
    /**
    * Format the notification content
    */
    function my_app_blog_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    
    	if ( ! ('my_app_blog_like' === $action || 'my_app_blog_comment' === $action)) {
    		return $action;
    	}
    
    	$post_title = get_the_title( $item_id );
    
    	if ('my_app_blog_comment' === $action) {
    		$custom_title = sprintf( esc_html__( 'New comment received', 'my_app' ), $post_title );
    		$custom_link  = get_permalink( $item_id );
    		if ( (int) $total_items > 1 ) {
    			$custom_text  = sprintf( esc_html__( 'You received "%1$s" new comments', 'my_app' ), $total_items );
    			$custom_link = bp_get_notifications_permalink();
    		} else {
    			$custom_text  = sprintf( esc_html__( 'Your post "%1$s" received a new comment', 'my_app' ), $post_title );
    		}
    
    	}
    
    	// WordPress Toolbar
    	if ( 'string' === $format ) {
    		$message = (!empty($custom_link)) ? '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>' : $custom_text;
    		$return = apply_filters( 'my_app_wiki_like_format', $message, $custom_text, $custom_link );
    
    		// Deprecated BuddyBar
    	} else {
    		$return = apply_filters( 'my_app_wiki_like_format', array(
    			'text' => $custom_text,
    			'link' => $custom_link
    		), $custom_link, (int) $total_items, $custom_text, $custom_title );
    	}
    
    	return $return;
    
    }	
    
    add_action('comment_post','my_app_comment_notification',10,2);
    
    /*
    * Send the notification after comment inserting
    */
    function my_app_comment_notification($comment_id, $comment_approved) {
    
    	if( 1 === $comment_approved ){
    		$comment_object = get_comment($comment_id);
    		$post_type = get_post_type($comment_object->comment_post_ID);
    		$current_user_id = get_current_user_id();
    
    		if($post_type == 'post') {
    			$post_object = get_post($comment_object->comment_post_ID);
    
    			if(my_app_is_notification_enabled_blog_comment()) {
    
    				bp_notifications_add_notification( array(
    					'user_id'           => $post_object->post_author,
    					'item_id'           => $comment_object->comment_post_ID,
    					'secondary_item_id' => $current_user_id,
    					'component_name'    => 'my_app_blog',
    					'component_action'  => 'my_app_blog_comment',
    					'date_notified'     => bp_core_current_time(),
    					'is_new'            => 1,
    				) );
    			}
    
    		}
    
    	}
    }
    kmligue
    Participant

    I installed https://wordpress.org/plugins/postman-smtp/ on my WP (v 4.6) + BuddyPress (v 2.6.2) site, then configured it to use my Gmail account’s SMTP server settings.

    The emails sent by the site uses the SMTP settings when:

    – A member registers and PMPRo (https://tl.wordpress.org/plugins/paid-memberships-pro/) sends out an email confirmation
    – Emails sent using the plugin (https://wordpress.org/plugins/email-users/)

    (I can see these sent emails in the “Sent” folder of my Gmail account.)

    However, when BuddyPress sends out an email (e.g. email notification for friend request, etc.), it seems to ignore the SMTP server settings I have configured. Instead, it uses the server’s default.

    How do I make BuddyPress email notifications send using my Gmail SMTP server settings?

    #258630
    danbp
    Participant

    Hi,

    the logout link is redirected to the same page. If you’re on your profile notifications screen, which is only intended for you, it is normal that when you logout from there, you’re redirected to a page not found message. Notifications is even private and not public.

    The solution is to redirect to an always public part of the site on logout.

    Add this snippet to child-theme’s functions.php

    //* Redirect WordPress Logout to Home Page
    add_action( 'wp_logout', create_function( '', 'wp_redirect( home_url() ); exit();' ) );

    Advice 1: use preferably the login widget, so the user stays on the same page where he attempt to login instead to be redirected to that boring wp-login page.

    Advice 2: on the Home (which is the member directory), you have all BP pages listed at the bottom. Remove them ! You certainly don’t need to give access to account activation or register page to your visitors…

    kmligue
    Participant

    I was able to create my custom email notification. I would like to add an option in the settings so that user can enable/disable this email notification. Has anyone successfully implemented like this before? Any ideas on how to do this?

    https://s11.postimg.io/6iq9f8lhf/email_notifications.png

    #258410
    steigw
    Participant

    It’s a staging site that doesn’t have public access, but I can put the code and info in here. Here is the complete code of the functions.php in the child theme. maybe I just put it all together wrong.

    <?php
    function nisarg_enqueue_styles() {
    
        $parent_style = 'nisarg-style';
    
        wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/css/bootstrap.css' );
        wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/font-awesome/css/font-awesome.min.css' );   
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    
        wp_enqueue_style( 'nisarg-child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style )
        );
    }
    add_action( 'wp_enqueue_scripts', 'nisarg_enqueue_styles' );
    ?>
    <?php
    function custom_wp_mail_from( $email ) {
            $handle = β€˜accounts’;
    	$find = 'http://'; 
    	$replace = '';
    	$link = get_bloginfo( 'url' );
    	$domain = str_replace( $find, $replace, $link );
    	return $handle . '@' . $domain ;
    }
    add_filter( 'wp_mail_from', 'custom_wp_mail_from' );
    ?>

    The email link is:http://mydomain.com/activate/JA0BvkK1Q0DND10SYegdOtkTMemhGUF0/

    When I click on it immediately, I get all this:

    Fatal error: Uncaught exception ‘phpmailerException’ with message ‘Invalid address: β€˜accounts’@mydomain.com’ in /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/class-phpmailer.php:946 Stack trace: #0 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/pluggable.php(352): PHPMailer->setFrom(‘\xE2\x80\x98accounts\xE2\x80\x99@…’, ‘WordPress’) #1 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/pluggable.php(1726): wp_mail(‘webmaster@arlin…’, ‘[My Dev Sit…’, ‘New user regist…’) #2 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-content/plugins/buddypress/bp-members/bp-members-functions.php(2031): wp_new_user_notification(18) #3 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-content/plugins/buddypress/bp-members/bp-members-screens.php(364): bp_core_activate_signup(‘JA0BvkK1Q0DND10…’) #4 [internal function]: bp_core_screen_activation(”) #5 /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/plugin.php(524): cal in /homepages/25/d283441938/htdocs/clickandbuilds/staging/wp-includes/class-phpmailer.php on line 946

    If I wait a while, then I get the normal webpage and it says “invalid activation key”. I don’t understand the significance of an immediate click on the link in the email vs. waiting a few more seconds, but it definitely matters.

    #258342
    Fantacular Designs
    Participant

    My brilliant husband is my coder… He figured out how to define the default component, and saved the day. I hope this helps others.

    define( 'BP_DEFAULT_COMPONENT', 'profile' );
    
    function bpfr_hide_tabs() {
    global $bp;
    
    	if ( bp_is_user() && !is_super_admin() ) {
    		bp_core_remove_nav_item( 'activity');
    		bp_core_remove_nav_item( 'notifications');
    		bp_core_remove_nav_item( 'messages' );
    		bp_core_remove_nav_item( 'forums' );
    		bp_core_remove_nav_item( 'groups' );
    		bp_core_remove_nav_item( 'settings' );
    	}
    	
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
    #258298
    rvnamb
    Participant

    My theme does not support notification alert so i used this code to show the notification count:
    <?php echo bp_notifications_get_unread_notification_count(bp_loggedin_user_id()); ?>

    But it is not clickable, can someone please help me with the link that i can paste inside the
    a href = ” ” <?php echo bp_notifications_get_unread_notification_count(bp_loggedin_user_id()); ?> /a

    so that it can redirect them to their notification page slug ?

    currently it http://www.example.comh/members/rvnamb/notifications/

    how can i replace rvnamb with the currently logged in user id ? i searched a lot but could not find a solution

    #258234
    Fantacular Designs
    Participant

    I also attempted to add them individually…

    function bpfr_hide_tabs() {
    global $bp;
    
    	if ( bp_is_user() && !is_super_admin() ) {
    		bp_core_remove_nav_item( 'activity' );
    		bp_core_remove_nav_item( 'notifications' );
    		bp_core_remove_nav_item( 'messages' );
    		bp_core_remove_nav_item( 'groups' );
    		bp_core_remove_nav_item( 'forums' );
    		bp_core_remove_nav_item( 'settings' );
    	}
    	
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
    

    I’ve noticed some changes require us to repeat ourselves, while others allow us to list changes within one line of code. Haven’t deciphered this anomaly just yet.

    #258232
    Fantacular Designs
    Participant

    I placed the following code in the bp-custom.php which was found under the wp-content -> plugins.

    function bpfr_hide_tabs() {
    global $bp;
    
    	if ( bp_is_user() && !is_super_admin() ) {
    		bp_core_remove_nav_item( 'notifications', 'activity', 'groups', 'messages', 'forums', 'settings');
    	}
    	
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
    

    It breaks my site, shuts it down. From what I’ve read, I am supposed to specify what tab is open when opening a profile. Otherwise, browsers don’t know what to display since default is “Activity” and I’m removing it… Can someone please tell me where I went wrong? I appreciate the help!

    #257925
    Humiges
    Participant

    Hey @buddycore,
    thanks for your reply.
    Sorry, I’ll try πŸ˜‰
    1, Well, we have users (buddypress) they post their stories from front end – using social articles plugin. Sometime, their stories have chapters… so, it would be nice to link them somehow. I didn’t find the way to do that, so I thought I would try it here — maybe a bit of brainstorming πŸ˜‰

    2, In regards of the images – I know lots of site have problems with copyrights, so I would like to control the images by allowing only selection from library.

    3, allow buddypress users to follow certain blog posts – so, when it’s edited or commented they receive notification? – — I hope this one is clear πŸ˜‰

    Thanks a lot πŸ™‚

    #257869
    Antonio
    Participant

    Hi guys, I created a custom notification that is added when an user receive a like on a custom post type.

    All good unitl now, but I noticed that if the post receive 2 likes, from 2 different users, the user receive only the first notification and not the second one.

    Any help would be really appreciated.

    
    //Component declaration
    if(!function_exists('my_custom_register_wiki_notification')) {
    	function my_custom_register_wiki_notification() {
    		// Register component manually into buddypress() singleton
    		buddypress()->my_custom_wiki = new stdClass;
    		// Add notification callback function
    		buddypress()->my_custom_wiki->notification_callback = 'my_custom_wiki_like_format_notifications';
    
    		// Now register components into active components array
    		buddypress()->active_components['my_custom_wiki'] = 1;
    	}
    };
    
    //Notification format declaration
    if(!function_exists('my_custom_wiki_like_format_notifications')) {
    	function my_custom_wiki_like_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    
    		// New custom notifications
    		if ( 'my_custom_wiki_like' === $action ) {
    
    			$wiki_post = get_post( $item_id );
    			$post_title = get_the_title( $item_id );
    
    			$custom_title = sprintf( esc_html__( 'Your post "%1$s" received a like', 'my_custom' ), $post_title );
    			$custom_text  = sprintf( esc_html__( 'Your post "%1$s" received a like', 'my_custom' ), $post_title );
    			$custom_link  = get_permalink( $item_id );
    
    			// WordPress Toolbar
    			if ( 'string' === $format ) {
    				$return = apply_filters( 'my_custom_wiki_like_format', '<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( 'my_custom_wiki_like_format', array(
    					'text' => $custom_text,
    					'link' => $custom_link
    				), $custom_link, (int) $total_items, $custom_text, $custom_title );
    			}
    
    			return $return;
    
    		}
    
    		return $action;
    
    	}
    }
    
    //Function that add the notification when like is triggered
    function my_custom_add_like() {
      //...
      //...
    
      if(my_custom_is_wiki_like_notification_enabled()) {
    		        bp_notifications_add_notification( array(
    			        'user_id'           => $post_object->post_author,
    			        'item_id'           => $post_id,
    			        'secondary_item_id' => get_current_user_id(),
    			        'component_name'    => 'my_custom_wiki',
    			        'component_action'  => 'my_custom_wiki_like',
    			        'date_notified'     => bp_core_current_time(),
    			        'is_new'            => 1,
    		        ) );
    	        }
      
    }
    
    #257597
    danbp
    Participant

    Don’t hack core files. (never !) Which language do you use ?

    Where have you done this ?
    I’ve took a look at the files and found out that the working ones are using __( "Foo %s", "buddypress" ) and the wrong ones are using _x( "Foo %s", "Blah blah blah", "buddypress" ).

    Actually all BP strings are working. If you need custom translation, you have to do that in po/mo and to use preferably the original strings. For example, if you build a template and want to use the notification count on it, you copy the original string to your work. If you don’t do that, you nedd 2 po/mo ! One for BP and one for your custom work. Which is certainly not the best and easiest solution.

    The notification count is defined in wp-content/plugins/buddypress/bp-notifications/classes/class-bp-notification-component.php

    The counter itself is inside a span and is defined separately.

    /* translators: %s: Unread notification count for the current user */
    _x( 'Notifications %s', 'Profile screen nav', 'buddypress' ),
    sprintf(
    	'<span class="%s">%s</span>',

    The bla bla bla part you mention is a comment for translators who indicates him the context. This comment appears in the pot file like: Notification %s [Profile screen nav]

    That’s BP’s default coding. You haven’t to modify this. Use it as is.

    If you have difficulty to translate such a string, you have to check your theme or any custom function you added (by hand or another plugin).

    The corresponding custom string should reflect the original one as gettext function wouldn’t translate a string which is not identic.

    __( "Foo %s", "buddypress" ) and _x( "Foo %s", "Blah blah blah", "buddypress" ) are both working, and do technicaly the same thing (foo = something) which let you modify “foo” in both case, but as the original string is _x( "Foo %s", "Blah blah blah", "buddypress" ), you couldn’t replace it with __( "Foo %s", "buddypress" ). It is the translation prefix (_x or __) which is the important thing here.

    Hope to be clear. And you’re right, unfortunately your changes will be overwriten at next BP update as you hacked core files.

    #257535
    ahmed3baid
    Participant

    Hi,
    I’m working on a wordpress website, and using Buddypress. I wanted to add posts notifications and it worked fine, except when I tried to filter them. First you need to know how I want to filter them.
    – I’ve a profile field named ‘Field’ which is a dropdown list with 5 options.
    – I have also 5 post categories with the exact names of the ‘Field’ values.
    – When a post is added, If it has (e.g. A,B,C) categories I want a notification for every user who has his ‘Field’ value is equal to A,B or C.

    Here is my code:

    foreach (users as $user) {
    $acc_type = xprofile_get_field_data(‘Field’, $user->ID);
    if (in_category($acc_type,$post_id)) {
    bp_notifications_add_notification( array(
    ‘user_id’ => $user->ID,
    ‘item_id’ => $post_id,
    ‘component_name’ => ‘custom’,
    ‘component_action’ => ‘custom_action’,
    ‘date_notified’ => bp_core_current_time(),
    ‘is_new’ => 1,
    ) );
    }

    }

    #257510
    mshane8
    Participant

    Hey Guys –

    I have a project where its a social community site where all the members create the site content on their own. I have 2 profiles(roles) that all users will fall under (employer & employee). Then I have 3 membership levels for each role (FREE, Standard & Premium). The idea is to pair up these users by category and control the level of access/features they have based on account type. So direct messaging is available only to premium members, push notifications only available to premium members. The more features and ability to build out your profile is based on your membership type. I would obviously add membership plugin to restrict access and capability as well as ecommerce capability for checkout.

    I know bbPress and BuddyPress are forums and social communities but will they integrate well into membership type communities where clients need to pay for additional access to social community and forum features?

    If not, is there a premium application that handles these types of projects?

    Thanks so much!

    #256722
    ah72king
    Participant

    I found a solution that can help

    
    <?php
    // For Custom Notification 
    // Registering Custom Componet 
    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' );
    
    // Formatting custom with respect to action
    function bp_custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
     		
     		//$item_id this your id which you can use to get your respected data
        	$data  = get_my_values_custom_function($item_id); // this is custom function it depend on your needs and data
        	$custom_title = $data->title;
        	$custom_link  = $data->link;
        	$custom_text  = $data->text;
    
        // New custom notifications
        if ( 'custom_action' === $action ) {
            
            // WordPress Toolbar
            if ( 'string' === $format ) {
                $return = apply_filters( 'custom_filter','Your custom notification for <a href="'.$custom_link.'">'.$custom_title.'</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', 'bp_custom_format_buddypress_notifications', 10, 5 );
    
    // Adding custom Notification in DB 
    function bp_custom_notification( $item_id, $author_id ) {
    
        if ( bp_is_active( 'notifications' ) ) {   // if notification is active from admin panel
        	// if notification is active from admin panel bp_notifications_add_notification function to add notification into database
            bp_notifications_add_notification( array(                        
                'user_id'           => $author_id, // User to whom notification has to be send
                'item_id'           => $item_id,  // Id of thing you want to show it can be item_id or post or custom post or anything
                'component_name'    => 'custom', //  component that we registered
                'component_action'  => 'custom_action', // Our Custom Action 
                'date_notified'     => bp_core_current_time(), // current time
                'is_new'            => 1, // It say that is new notification
            ) );
        }
    }
    add_action( 'custom_hooks', 'bp_custom_notification', 10, 2);
    /**
    * custom_hooks is action name which will be call by do_action() function
    * bp_custom_notification your function name
    * 10 is priority number
    * 2 is number of parameter 
    */
    
    /****
    * Now Where to call custom_hooks and how 
    */
    
    do_action('custom_hooks', $item_id, $author_id );
    
    /****
    * place it where you want to call this action and pass parameter
    */ 
    
    #256710
    ah72king
    Participant

    I have custom plugin in which i have review approved and delete functions so when i do some sort of bulk action like delete or i approved a review.
    i want to generate a bp custom notifications at that user dashboard or member page which review was approved or deleted
    i place this where i perform approved action

    do_action('review-approved');

    Then i make function below


    function bp_review_add_notification() {
    if ( bp_is_active( 'notifications' ) ) {
    bp_notifications_add_notification( array(
    'user_id' => 1, // this is one because for testing just admin now
    'component_name' => 'review',
    'component_action' => 'review_approved',
    'date_notified' => bp_core_current_time(),
    'is_new' => 1,
    ) );
    }
    }
    add_action( 'review-approved', 'bp_review_add_notification',10,5);

    Review is added in database i checked that but it is not shown on dashboard or member page
    how to do that

    or can you refer any complete guide to create a custom notification upon some action

    socialc
    Participant

    <?php echo bp_notifications_get_unread_notification_count(bp_loggedin_user_id()); ?>

    You can build your own menu using this inside to show the count.

Viewing 25 results - 276 through 300 (of 768 total)
Skip to toolbar