Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'notification user id'

Viewing 25 results - 101 through 125 (of 768 total)
  • Author
    Search Results
  • #307730
    Tom Swain
    Participant

    For anyone else trying to figure this out, I didn’t find THE solution, but I did find A solution… it’s simple javascript. Wrap your notification in a div with the class “count” or whatever works for you, and hide it when its content is ‘0’.

    
    <div class="count">
    	<?php echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ); ?>
    </div>
    
    
    <script type="text/javascript">
    	//HIDE NOTIFICATION IF COUNT IS ZERO
    	let divs = document.getElementsByClassName('count');
    
    	for (let x = 0; x < divs.length; x++) {
    	    let div = divs[x];
    	    let content = div.innerHTML.trim();
    
    	    if (content == '0') {
    	        div.style.display = 'none';
    	    }
    	}
    </script>
    
    #307652
    werny
    Participant

    Hi there,

    since a few days I do not get the notification by email, when a new buddy user signs up.
    Is there a way to activate that mail or to activat that again?
    Any ideas?

    #307617
    Tom Swain
    Participant

    Thank you so much for your reply!

    If I’m understanding you correctly, I put the code in like this…

    
    <?php
    	$count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
    	$count = empty( $count ) ? '' : $count;
    ?>
    

    But that doesn’t seem to be working. Am I doing something wrong?

    #307615
    raviousprime
    Participant

    Hello,

    you can do something like. It will print nothing when got 0.

    $count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
    $count = empty( $count ) ? '' : $count;

    and use this variable in your code.

    Regards
    Ravi

    #307499
    Tom Swain
    Participant

    I’m building a notification dropdown outside of the logged-in users profile on a sidebar.

    I’m using this line of code to get the count

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

    The notification count does appear, and for the correct user, but does not go away once the count is 0.

    How can I get the count to display:none when the count is 0?

    This is my first ever support post on any platform, so please take it easy on me if I didn’t include all the proper information. Thanks!

    michaeljcheney21
    Participant

    Ive tried multiple times with different usernames and emails but the registration page is not working;

    Register

    1. Which version of WordPress are you running?

    WordPress 5.2.2

    2. Did you install WordPress as a directory or subdomain install?

    no, on the root

    3. If a directory install, is it in root or in a subdirectory?

    root

    4. Did you upgrade from a previous version of WordPress? If so, from which version?

    no

    5. Was WordPress functioning properly before installing/upgrading BuddyPress (BP)? e.g. permalinks, creating a new post, commenting.

    yes

    6. Which version of BP are you running?

    Version 4.4.0

    7. Did you upgraded from a previous version of BP? If so, from which version?

    no

    8. Do you have any plugins other than BuddyPress installed and activated? If so, which ones?

    Akismet Anti-Spam
    Activate | Delete
    Used by millions, Akismet is quite possibly the best way in the world to protect your blog from spam. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.

    Version 4.1.2 | By Automattic | View details
    Select bbPress
    bbPress
    Deactivate | Settings | About
    bbPress is forum software with a twist from the creators of WordPress.

    Version 2.5.14 | By The bbPress Community | View details
    Select BuddyPress
    BuddyPress
    Deactivate | Settings | Hello, BuddyPress!
    BuddyPress adds community features to WordPress. Member Profiles, Activity Streams, Direct Messaging, Notifications, and more!

    Version 4.4.0 | By The BuddyPress Community | View details
    Select Contact Form 7
    Contact Form 7
    Settings | Deactivate
    Just another contact form plugin. Simple but flexible.

    Version 5.1.4 | By Takayuki Miyoshi | View details
    Select Envato Market
    Envato Market
    Deactivate
    WordPress Theme & Plugin management for the Envato Market.

    Version 2.0.1 | By Envato | Visit plugin site
    Select Featured Image from URL
    Featured Image from URL
    Activate | Delete
    Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.

    Version 2.6.0 | By Marcel Jacques Machado | View details
    Select Google Captcha (reCAPTCHA) by BestWebSoft
    Google Captcha (reCAPTCHA) by BestWebSoft
    Settings | Deactivate
    Protect WordPress website forms from spam entries with Google Captcha (reCaptcha).

    Version 1.51 | By BestWebSoft | View details | Settings | FAQ | Support
    Select Hello Dolly
    Hello Dolly
    Activate | Delete
    This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from Hello, Dolly in the upper right of your admin screen on every page.

    Version 1.7.2 | By Matt Mullenweg | View details
    Select Leadpages Connector
    Leadpages Connector
    Deactivate
    Connect your Leadpages account to your WordPress site to import Leadpages and Leadboxes

    Version 2.1.6.21 | By Leadpages | Visit plugin site
    Select OptimizePress
    OptimizePress
    Deactivate
    OptimizePress is the essential plugin for marketers. Create squeeze pages, sales letters and much more with ease.

    Version 2.5.21 | By OptimizePress | Visit plugin site
    Select Post Views Counter
    Post Views Counter
    Settings | Deactivate
    Post Views Counter allows you to display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.

    Version 1.3.1 | By Digital Factory | View details | Support
    Select Socialize Plugin
    Socialize Plugin
    Deactivate
    A required plugin for Socialize theme you purchased from ThemeForest. It includes a number of features that you can still use if you switch to another theme.

    Version 3.10 | By GhostPool
    Select The Events Calendar
    The Events Calendar
    Deactivate | Settings | Calendar
    The Events Calendar is a carefully crafted, extensible plugin that lets you easily share your events. Beautiful. Solid. Awesome.

    Version 4.9.7 | By Modern Tribe, Inc. | View details | Support | View All Add-Ons
    Select Theia Sticky Sidebar
    Theia Sticky Sidebar
    Deactivate
    Glues your website’s sidebars, making them permanently visible while scrolling.

    Version 1.8.0 | By WeCodePixels | Visit plugin site
    Select Visual Sidebar Editor
    Visual Sidebar Editor
    Deactivate
    An addon that allow you to use WPBakery Visual Composer or wordress editor to override sidebars

    Version 1.2.5 | By ERROPiX | Visit plugin site
    Select WishList Memberâ„¢ 3.0
    WishList Memberâ„¢ 3.0
    Deactivate
    WishList Memberâ„¢ 3.0 is the most comprehensive membership plugin for WordPress users. It allows you to create multiple membership levels, protect desired content and much more. For more WordPress tools please visit the WishList Products Blog. Requires at least WordPress 4.0 and PHP 5.4

    Version 3.0.6282 | By WishList Products | Visit plugin site
    Select WordPress Automatic Plugin
    Wordpress Automatic Plugin
    Deactivate
    WordPress Automatic posts quality articles, Amazon products, Clickbank products, Youtube videos, eBay items, Flicker images, RSS feeds posts on auto-pilot and much more.

    Version 2.3.3 | By Miled | View details
    Select WPBakery Page Builder
    WPBakery Page Builder
    Settings | Deactivate
    Drag and drop page builder for WordPress. Take full control over your WordPress site, build any layout you can imagine – no programming knowledge required.

    Version 6.0.5 | By Michael M – WPBakery.com | Visit plugin site
    Select Yoast SEO
    Yoast SEO
    FAQ | Premium Support | Settings | Deactivate
    The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more.

    9. Are you using a standard WordPress theme or customized theme?

    Socialize Child Theme

    10. Which theme do you use ?

    Socialize Child Theme

    11. Have you modified the core files in any way?

    no

    12. Do you have any custom functions in bp-custom.php?

    no

    13. If running bbPress, which version? Or did your BuddyPress install come with a copy of bbPress built-in?

    built in i think

    14. Please provide a list of any errors in your server’s log files. https://codex.wordpress.org/Debugging_in_WordPress

    dont think i have these – just cant get registered as a pretend user on the registration page

    15. Which company provides your hosting?

    D9

    16. Is your server running Windows, or if Linux; Apache, nginx or something else?

    Apache i think

    17. Which BP Theme are you using?

    dont know

    18. Have you overloaded any BuddyPress template files.

    no

    19. Any other site customisations that might have a bearing on the issue?

    no

    #307349
    Raval
    Participant

    Welcome,
    I’m having trouble personalizing notifications for my site. I would like to display notifications only for specific “component_name” or “component_action” (in the database refer to the same notification)
    I wanted to check with the “if {}” statement whether the notification:
    bp_notifications_get_notifications_for_user ($ user_id, ‘string’);
    is equal to the “component_name” with the value “bp_wcamp” and only then display them.
    I hope I have described the problem clearly.
    Is there anyone who can help me?

    kaneesha
    Participant

    I try to get a different color for “new” notifications could somebody help please?

    My actual code in my theme functions.php:

    //notification alerts for posts
    function my_nav_menu_notif_counter($menu) {      
            if (!is_user_logged_in())
                    return $menu;
            else
                    $notif = '<a class="notices" 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>';
                    $menu = $menu . $notif;
                    return $menu;
    }
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter' );
    
    //notification alerts for messages
    function my_nav_menu_msg_counter($menu) {      
            if (!is_user_logged_in())
                    return $menu;
            else
                    $notif = '<a class="notices" href="' . bp_loggedin_user_domain() . 'messages/' . '"><span class="noticecount2"><i class="noticecount2title">Messages</i>'. bp_get_total_unread_messages_count( bp_loggedin_user_id() ) .'</span></a>';
                    $menu = $menu . $notif;
                    return $menu;
    }
    
    

    Thank you in advance 🙂

    #306624
    salvatore77
    Participant

    I have created my custom component for custom notifications, but id doesn’t work. This is the code:

    <?php
    /**
     * Class to serve notification Calls.
     *
    
     */
    
    	class MyPlugin___Notifications extends BP_Component {
    
    	    protected $component_name = 'MyPlugin__';
    
    		/**
    		 * Constructor.
    		 *
    		 * @since    1.0.0
    		 * @access   public
    		 * @author   Wbcom Designs
    		 */
    		public function __construct() {
    			$this->slug = $this->component_name;
    
    			parent::start(
    			    $this->component_name, esc_html__( 'Custom', 'bp-MyPlugin-Custom' ), dirname( __FILE__ )
    			);
    
    			buddypress()->active_components[ $this->component_name ] = '1';
    			
    		}
    		
    
    		public function setup_globals( $args = array() ) {
    			parent::setup_globals(
    				array(
    					'slug'                  => $this->component_name,
    					'has_directory'         => false,
    					'notification_callback' => 'MyPlugin_custom_format_buddypress_notifications',
    				)
    			);
    		}
    
    		public function setup_actions() {
    			parent::setup_actions();
    		}
    		
    		public function add_MyPlugin_notification_format($action, $item_id, $secondary_item_id, 
    		                                                      $user_id, $format = 'string' ){
    		    global $wpdb;
    		    if ( bp_is_active( 'notifications' ) ) {
    		        if ( 'custom_action' === $action ) {
    		           //there is a php code
    		            return $return;
    		        }
    		    }
    		}
    
    		public function component_name() {
    			return $this->component_name;
    		}
    	}
    
    function init_MyPlugin___notifications_component(){
        buddypress()->MyPlugin___notifications =  new MyPlugin___Notifications();
        buddypress()->MyPlugin___notifications->notification_callback = 'MyPlugin_custom_format_buddypress_notifications';
       
    }
    add_action( 'bp_init', 'init_MyPlugin___notifications_component', 40 );
    
    add_filter( 'bp_notifications_get_notifications_for_user', 'MyPlugin_custom_format_buddypress_notifications', 10, 5 );
    
    function MyPlugin_custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
        $return = buddypress()->MyPlugin___notifications->add_MyPlugin_notification_format( $action, $item_id, 
            $secondary_item_id, $total_items, $format);
    }
    
    
    #306073
    fulviods
    Participant

    Hi

    I have the last version of wordpress and buddypress but our site is not visible (its private)
    You can only see the home page http://www.test2.allianceschlumberger.org

    I would like to replace the username by the first name and last name in the forums but also in the email notifications..how can i do it ? i didnt find a valid solution

    shanebp
    Moderator

    That’s because the function makes a call to another function that calls a class function that has a param that defaults to ‘only new’.

    Open: buddypress\bp-notifications\classes\class-bp-notifications-notification.php
    and look at the args for public static function get( $args = array() )

    Untested, but try:

    $notifications = BP_Notifications_Notification::get( array( 
    	'user_id' => get_current_user_id(),
    	'is_new'  => 'both'				
    ) );
    #305587
    btees
    Participant

    I’m struggling with putting together Custom Notifications.

    I’ve been trying to use this: https://gist.github.com/modemlooper/9693b591d8c36288496d
    Without success.

    I’ve been able to add the text for my new notification to \bp-activity\bp-activity-notifications.php
    Which is fine as a temporary solution but obviously isn’t update proof.

    I’m putting together a system where a user can give a category to their activity update and then users who are in that category (as set on their profile) will get a notification about that update.

    The notification is generated like this in bp-custom.php:

    function seo_activity_update_reply_add_notification( $activity, $activity_id, $user_id ) {
    	global $wpdb;
    	$post_cat = $_POST['bpcat'];
    	$users = $wpdb->get_results ( "SELECT user_id FROM wp_bp_xprofile_data WHERE value='$post_cat'" );
    	$metasjson = json_decode( json_encode($users), true);
    	
    		
    	$newList = array();
    foreach($metasjson as $key=>$listItem) {
     $newList[$key] =  $listItem['user_id'];
     
     $posts = '';
    
    }
    	
    	foreach ($newList as $user) {
    	bp_notifications_add_notification( array(
    		'user_id'           => $user,
    		'item_id'           => $user_id,
    		'secondary_item_id' => $activity_id,
    		'component_name'    => buddypress()->activity->id,
    		'component_action'  => 'industry_post',
    		'date_notified'     => bp_core_current_time(),
    		'is_new'            => 1,
    		'meta_key'			=> 'category',
    		'meta_value'			=> $post_cat
    	) );
    	}
    }
    add_action( 'bp_activity_posted_update', 'seo_activity_update_reply_add_notification', 10, 3 );

    Then in \bp-activity\bp-activity-notifications.php I’ve added this to the bp_activity_format_notifications function:

    case 'industry_post':
    		$action_filter = $action;
    		$activity_id = $user_id;
    						$title         = sprintf( __( '@%s Industry Post', 'buddypress' ), bp_get_loggedin_user_username() );
    			$amount        = 'single';
    			$seouser = bp_core_get_user_displayname($activity_id );
    			$seouserurl = bp_core_get_username($item_id );
    			// $link          = home_url().'/members/'.$seouserurl.'/'. bp_get_activity_slug() . '/'.$user_id;
    			$link = bp_activity_get_permalink( $item_id ) ;
    
    			
    					
    				$text = sprintf( __( '%1$s is looking for someone in your industry', 'buddypress' ), $seouser );
    					
    					break; 

    But I can’t seem to figure out how to get this to work as a stand alone function in bp-custom.php

    #305549
    polywebjeff
    Participant

    Switching to the default aarvark theme did indead remove the error messages. I’ve switched back to the child theme, and removed mycode from bp-custom. No results. My BP templates do not contain bp_nav, but I didn’t took the time to change the file versions in the top comments. I have those custom files:

  • aarvark-child/buddypress/members/single/myorganization/edit.php
  • /**
     * BuddyPress - Members Single Profile Edit
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     * @version 3.0.0
     */
  • aarvark-child/buddypress/members/single/myorganization/profile-loop.php
  • /**
     * BuddyPress - Members Profile Loop
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     * @version 3.0.0
     */
  • aarvark-child/buddypress/members/single/myorganization/profile-wp.php
  • /**
     * BuddyPress - Members Single Profile WP
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     * @version 3.0.0
     */
  • aarvark-child/buddypress/members/single/profile/edit.php
  • /**
     * BuddyPress - Members Single Profile Edit
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     * @version 3.0.0
     */
  • aarvark-child/buddypress/members/single/home.php
  • /**
     * BuddyPress - Members Home
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     */
  • aarvark-child/buddypress/members/single/member-header.php
  • /**
     * BuddyPress - Users Header
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     */
  • aarvark-child/buddypress/members/register.php
  • no version in comments

    In my functions.php file:

    // New buddypress nav items
    
    function add_bp_menu_items() {
        global $bp;
        //Remove unwanted nav items
        bp_core_remove_nav_item( 'activity' );
        bp_core_remove_nav_item( 'forums' );
        bp_core_remove_nav_item( 'user-media' );
    //    bp_core_remove_subnav_item( 'profile', 'public' );
        unset($bp->bp_options_nav['profile']['public']);
        unset($bp->bp_options_nav['profile']['change-avatar']);
        unset($bp->bp_options_nav['profile']['change-cover-image']);
        unset($bp->bp_options_nav['settings']['profile']);
        unset($bp->bp_options_nav['settings']['data']);
    
        $bp->bp_options_nav['profile']['name'] = 'My Profile';
    }
    add_action( 'bp_setup_nav', 'add_bp_menu_items', 15 );
    
    // Change Profile menu/tab order
    function rt_change_profile_tab_order() {
        global $bp;
    
        $bp->members->nav->edit_nav( array(
            'name' => 'My Profile',
        ), 'profile' );
    
        $bp->members->nav->edit_nav( array(
            'position' => 1,
        ), 'profile' );
    
        $bp->members->nav->edit_nav( array(
            'position' => 65,
        ), 'notifications' );
    }
    add_action( 'bp_init', 'rt_change_profile_tab_order', 999 );
#305501

In reply to: Notifications settings

Debora1976
Participant

Hi,

The form is not in settings:

<?php

/**

* BuddyPress – Members Settings Notifications

*

* @package BuddyPress

* @subpackage bp-legacy

* @version 3.0.0

*/

/** This action is documented in bp-templates/bp-legacy/buddypress/members/single/settings/profile.php */

do_action( ‘bp_before_member_settings_template’ ); ?>

<h2 class=”bp-screen-reader-text”><?php

/* translators: accessibility text */

_e( ‘Notification settings’, ‘buddypress’ );

?></h2>

<form action=”<?php echo bp_displayed_user_domain() . bp_get_settings_slug() . ‘/notifications’; ?>” method=”post” class=”standard-form” id=”settings-form”>

<p><?php _e( ‘Send an email notice when:’, ‘buddypress’ ); ?></p>

<?php

/**

* Fires at the top of the member template notification settings form.

*

* @since 1.0.0

*/

do_action( ‘bp_notification_settings’ ); ?>

<?php

/**

* Fires before the display of the submit button for user notification saving.

*

* @since 1.5.0

*/

do_action( ‘bp_members_notification_settings_before_submit’ ); ?>

<div class=”submit”>

<input type=”submit” name=”submit” value=”<?php esc_attr_e( ‘Save Changes’, ‘buddypress’ ); ?>” id=”submit” class=”auto” />

</div>

<?php

/**

* Fires after the display of the submit button for user notification saving.

*

* @since 1.5.0

*/

do_action( ‘bp_members_notification_settings_after_submit’ ); ?>

<?php wp_nonce_field(‘bp_settings_notifications’ ); ?>

</form>

<?php

/** This action is documented in bp-templates/bp-legacy/buddypress/members/single/settings/profile.php */

do_action( ‘bp_after_member_settings_template’ );

#304722
werny
Participant

user A sends a friend request to user B.
User B gets a notification (you got 1 friend request) until he accepts or refuses.
But it happens that user A meanwhile deletes his profile, even before user B did some action.
But in that case the notification will stay there at users B profile
and cannot be deleted anymore:

“You have 1 friend request”
By clicking on the link, there are no requests, because the user is gone.

How can I fix that?

#304710
chickencurry
Participant

Hi there,

I am new to buddyPress and installed it on my site. My theme doesn’t natively support buddypress so I have to set it up to my liking on my own. Here a few things I want to implement, and it’s a lot but maybe you can help me.

1.) Where can I change the layout of the profile? And make the navigation horizontal

2.) Is it possible to make profiles for users editible from the front end, so they don’t need any backend access? (And upload avatars / covers or choose from existing images)

3.) Is there a free plugin for a facebook like wall

4.) Can I change the address of the notification emails sent so it doesn’t say wordpress@mydomain.com

5.) Is it possible to include a function that gives members the chance to give reationcs on bbpress postings?

6.) can i include member titles / ranks that are display below there image in bbpress postings and beside the username in their profiles

7.) How can users create own groups?

Thank you it’s a lot but I want to offer my users the best experience they can get

#304517
winnischneider
Participant

Ok I got it. sorry but see now that we use really a plugin called “notification” for this job.
Its a while ago when I made this installation. But would it be possible to send a email to users from the wordpress side without plugin to members?

#304145
werny
Participant

Hi there,

I got lots of E-Mail returns of my users notifications.
That happens, when the enter a non existing email in their account.
But how can they even enter a non valid email? All Emails must be approved by link in BB.
Or is it possible that the user have deleted their mail account after having singed up ad my page?
How can I prevent that?
It is very annoying to get all those returning mails – and the user will not get his notification either.

#303695
cdtrue
Participant

Thank you! That gets me half way 🙂

I still get the notification after registration about the activation link – and I do not think that the little old ladies using my site will get that they have to activate and then wait for approval (to much for them to take in).

So I now are able to stop users with the extra My Private Site-plugin and the messages sent out from BP egistration works as a charm. There is only one (Account Approved Email) that actually is sent though – I can not figure out how to get the other ones to override the BuddyPress – activation-email. And if I de-activate that e-mail no e-mail is sent at all.

Also when I click on the register-button in the registration form I get redirected to a page that says that my account needs to be activated and I have to check my e-mail to do so. I want to loose it or change the text.

If they try to log in anyway they get the wordpress opt of re-sending the activation-link. Same thing here – preferably change the text.

But where do I find the texts? I guess the re-direct page is automated from BP, the other one is from WP.

Any tips?

#303511
sitesfromash
Participant

Hi. I have chosen to disable the Notifications component in hopes that users would not receive notification emails. This means, however, that there is no page where users can change their notification settings. When editing the activation and reset password emails, as well as the email sent when group details have been changed, I noticed that there is an Unsubscribe link still showing. Can you please let me know how I am able to prevent the link from showing or customize it to saying Home Page and redirecting those who click it to my home page? I appreciate any feedback which you can provide me. Have a great day.

#303170
FTLRalph
Participant

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);
#302958
Lena Stergatou
Participant

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

#302956
Artyom
Participant

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).

#302937
shanebp
Moderator

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 );
#302936
pavelmititel
Participant

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
Bug view on frontpage

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 );
Viewing 25 results - 101 through 125 (of 768 total)
Skip to toolbar