Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'notification user id'

Viewing 25 results - 326 through 350 (of 772 total)
  • Author
    Search Results
  • Masoud
    Participant

    hi.
    i want to hide some tabs only for non-admins.
    for example “Compose
    underMessage > Compose.
    in bp-messages/classes/class-bp-component.php lines:199 & 287.
    it’s possible to add a conditional if().

    <strong>if(current_user_can(administrator))</strong>
    {
    $sub_nav[] = array(
    'name'=> __( 'Compose', 'buddypress' ),
    'slug'=> 'compose',
    'parent_url'=> $messages_link,
    'parent_slug'=> $slug,
    'screen_function'=> 'messages_screen_compose',
    'position'=> 30,
    'user_has_access'=> $access
    }

    and do this for line 287.
    so, both the Compose tab and the ability to composing a msg will be in admin hands.
    BUT it’s not a good way to hack core codes!
    so how can i do this?

    the things i want to hide from non-admins:
    1) Notification tab
    2) Compose (sub-nav)
    3) hide the panel and restrict the access to change Account email (from Setting > General)

    thanks in advance.

    cahara
    Participant

    Hey all,

    Been digging for a solution but can’t seem to find one. My site has 2 registration forms (Form A and Form B) on separate pages that are working great. When users signup to Form B a hidden field called subscriber_type is populated. Otherwise Form A and B are identical. Once the forms are submitted a user should only be auto-activated and logged-in if this subscriber_type field is populated.

    So far users filling out Form B are activated (and don’t get the activation email) and are logged in. But users filling out Form A aren’t getting their activation emails either even though they should. Looks like no users are getting any activation emails, regardless of the form they fill.

    Is there any way to make sending of the activation emails conditional?

    What I’ve tried so far:

    
    // Auto-activate users from Form B (This works)
    function auto_activate_user( $user_id ) {
    
        $subscriber_type = $_POST['subscriber_type'];
        if ($subscriber_type || $subscriber_type === 'current_subscriber'){
            global $wpdb;
    
            //Hook if you want to do something before the activation
            do_action('bp_disable_activation_before_activation');
    
            $activation_key = get_user_meta($user_id, 'activation_key', true);
            $activate = apply_filters('bp_core_activate_account', bp_core_activate_signup($activation_key));
            BP_Signup::validate($activation_key);
            $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 0 WHERE ID = %d", $user_id ) );
    
            //Add note on Activity Stream
            if ( function_exists( 'bp_activity_add' ) ) {
                $userlink = bp_core_get_userlink( $user_id );
    
                bp_activity_add( array(
                    'user_id' => $user_id,
                    'action' => apply_filters( 'bp_core_activity_registered_member', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $user_id ),
                    'component' => 'profile',
                    'type' => 'new_member'
                ) );
    
            }
            //Send email to admin
            wp_new_user_notification( $user_id );
            // Remove the activation key meta
            delete_user_meta( $user_id, 'activation_key' );
            // Delete the total member cache
            wp_cache_delete( 'bp_total_member_count', 'bp' );
    
            //Hook if you want to do something before the login
            do_action('bp_disable_activation_before_login');
    
            //Automatically log the user in	.
            $user_info = get_userdata($user_id);
            wp_set_auth_cookie($user_id);
    
            do_action('wp_signon', $user_info->user_login);
    
            //Hook if you want to do something after the login
            do_action('bp_disable_activation_after_login');
    
        }
    }
    
    // Fix validation on Form B (This works)
    function fix_signup_form_validation_text() {
        $subscriber_type = $_POST['subscriber_type'];
        if ($subscriber_type || $subscriber_type === 'current_subscriber'){
            return false;
        }
    }
    
    // Disable autivation email only for Form B (This doesn't work)
    function disable_activation_email() {
        $subscriber_type = $_POST['subscriber_type'];
        if ($subscriber_type || $subscriber_type === 'current_subscriber'){
            return false;
        }
    }
    
    add_action( 'bp_core_signup_user', 'auto_activate_user');
    add_filter( 'bp_registration_needs_activation', 'fix_signup_form_validation_text');
    add_filter( 'bp_core_signup_send_activation_key', 'disable_activation_email');
    
    #253425
    Andrew Tibbetts
    Participant

    I am trying to add a new notification for all members of a group when a new user joins a group. I have registered a new dummy component, can successfully get the notification into the db, but returning the notification for formatting / display comes up empty. Here’s my code:

    
    add_filter( 'bp_notifications_get_registered_components', 'custom_bp_notifications_get_registered_components' );
    function custom_bp_notifications_get_registered_components( $component_names = array() ) {
     
    	if ( ! is_array( $component_names ) ) {
    
    		$component_names = array();
    	}
     
    	array_push( $component_names, 'custom' );
     
    	return $component_names;
    }
    
    add_action( 'groups_join_group', 'custom_groups_join_group', 10, 2 );
    function custom_groups_join_group( $group_id, $user_id ) {
    	
    	if ( bp_is_active( 'notifications' ) ) {
    		
    		if ( bp_group_has_members( 'group_id='.$group_id.'&per_page=10000000' ) ) {
    			
    			while ( bp_group_members() ) {
    				
    				bp_group_the_member();
    				
    				if ( bp_get_group_member_id() != $user_id ) {
    
    					bp_notifications_add_notification(array(
    						'user_id' 		=> bp_get_group_member_id(),
    						'item_id' 		=> $group_id,
    						'secondary_item_id' 	=> $user_id,
    						'component_name' 	=> 'custom',
    						'component_action' 	=> 'custom_group_join',
    						'date_notified' 	=> bp_core_current_time(),
    						'is_new' 		=> 1,
    					));
    				}
    			}
    		}
    	}
    }
    
    add_filter( 'bp_notifications_get_notifications_for_user', 'custom_bp_notifications_get_notifications_for_user', 10, 5 );
    function custom_bp_notifications_get_notifications_for_user( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    
    	if ( $action === 'custom_group_join' ) {
    
    		$group_id = $item_id;
    		$joining_user_id = $secondary_item_id;
    
    		$group = groups_get_group( array( 'group_id' => $group_id ) );
    		$group_link = bp_get_group_permalink( $group );
    
    		$user_fullname = bp_core_get_user_displayname( $joining_user_id );
    		$user_link = bp_core_get_user_domain( $joining_user_id );
    
    		$text = $user_fullname . ' joined the group ' . $group->name;
    		$notification_link = $group_link . 'admin/membership-requests/?n=1';
    		
    		if ( 'string' === $format ) {
    
    			$return = apply_filters(
    				'bp_groups_' . $action . '_notification', '<a href="' . $user_link . '" title="' . $user_fullname . '">' . $user_fullname . '</a> joined the group <a href="' . $group_link . '" title="' . $group->name . '">' . $group->name . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link );
    		}
    		else {
    
    			$return = apply_filters( 'bp_groups_' . $action . '_notification', array(
    				'link' => $notification_link,
    				'text' => $text
    			), $group_link, $user_fullname, $group->name, $text, $notification_link );
    		}
    	
    		return $return;
    	}
    }
    
    chiragsharma11
    Participant

    Hey Guys,
    I know that a lot of you guys have asked this question before but I still can’t find a solution to this problem anywhere.

    Whenever I try to set up new user, I never get the activation email. I hhave the WP SMTP plugin installed with the “from” email set to donotreply@mysite.com and all correct SMTP localhost and port settings. That being said, I get all the other emails , that is from the contact forms I have and I also get the BuddyPress notification emails such as the user addition, friend request. It is just that I am not getting any activation link at all. I have tested all the plugins (disabling and enabling them together and separately), but that doesn’t work out either. This is the only site left before I hand it over to the client, so any help would be appreciated.

    #253098
    bogski
    Participant

    Hi,

    Im looking at the email tokens available for use with BuddyPress and the automated emails sent from wordpress.

    My question relates to this token in particular…..{{{unsubscribe}}}

    If a user clicks this, does it just unsubscribe them from the email notifications, or does it cancel their registration?

    you know how sometimes you get an email and at the bottom there is a link along the lines of

    “Didnt sign up for our website? click here to unsubscribe”

    Is that what that token is for?

    Thanks,

    Phil

    jl3nz
    Participant

    I am having an issue with my Buddypress Notification Settings not saving. When you change any options from “Yes” to “No” and click the “Save” button at the bottom of the page, the page reloads but the changed options don’t save.

    WP version 4.4.1
    Theme PageLines Framework 2.4.6
    PHP version 5.4.13
    bbPress version 2.5.8-5815
    site url http://www.wpfilm.com
    Active Plugins Name and Version
    – p1 Gravity Forms 1.9.15
    – p2 Add Shortcodes Actions And Filters 2.0.3
    – p3 Akismet 3.1.8
    – p4 BAW Multipass for Protected Pages 1.4
    – p5 bbP Toolkit 1.0.6
    – p6 bbPress 2.5.8
    – p7 Better Notifications for WordPress 1.3.9.5
    – p8 BuddyPress Username Changer 1.1
    – p9 BuddyPress 2.4.3
    – p10 CloudFlare 1.3.20
    – p11 Display Categories Widget 2.0
    – p12 Disqus Comment System 2.84
    – p13 Gravity Forms ActiveCampaign Add-On 1.3.1
    – p14 Gravity Forms Authorize.Net Add-On 2.1.1
    – p15 Gravity Forms MailChimp Add-On 3.7.1
    – p16 Gravity Forms PayPal Standard Add-On 2.6
    – p17 Gravity Forms Survey Add-On 2.6
    – p18 Like Button Voting & Rating 2.1.9
    – p19 MemberPress Active Campaign 1.0.4
    – p20 MemberPress AWS 1.2.5
    – p21 MemberPress Developer Tools 1.0.2
    – p22 MemberPress Importer 1.2.3
    – p23 MemberPress to VHX.tv 1.0
    – p24 MemberPress WP Films Addons 1.0
    – p25 MemberPress Developer Edition 1.2.7
    – p26 Nav Menu Roles 1.7.7
    – p27 Open Graph Metabox 1.4
    – p28 bbPress for PageLines 2.0.2
    – p29 Recent Posts Widget Extended 0.9.9.5
    – p30 Shortcodes in Menus 3.1
    – p31 Stream 3.0.5
    – p32 Update Control 1.5
    – p33 UpdraftPlus – Backup/Restore 1.11.28
    – p34 WP Better Emails 0.3

    Zox Zin Min
    Participant

    Last two years ago, one of buddypress user MLDIA asked this question. I am also want to know and would like to make features that ..

    1- Users can upload their resume.
    2- Users can find jobs, people and business opportunities recommended by other users.
    3- Employers can list jobs and search for potential candidates.
    4- Job seekers can review the profile of hiring managers and discover which of their existing contacts can introduce them.
    5- Users can post their own photos and view photos of others to aid in identification.
    6- Users can follow different companies and can receive notifications about the new joining and offers available.
    7- Users can save (bookmark) jobs that they would like to apply for.
    8- Users can “like” and “congratulate” each other’s updates and new employments.
    9- Users can see who has visited their profile page.
    10- Questions & Answers
    11- Advertisments (for admin a.k.a me)
    12- Job listings
    13- “Apply with” button
    14- “Saved Jobs” button
    15- Users can endorse each other’s skills.
    16- Influencers (like the one in the linkedIn)

    Please help me. Thanks all.

    #252726
    Henry Wright
    Moderator

    Try this:

    $count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
    if ( $count > 0 ) {
        echo $count;
    } else {
        // The notif count is 0.
    }
    #252725
    jameshh93
    Participant

    At moment im using this code which display 0 if there are no notifcations how can I display nothing if there are 0 notifcations?

    echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );

    Also is there a same sort of code for friends count too and or mentions?

    Thank you!

    singhnavjeet
    Participant

    Hey !

    Is there a way where I can have Friends request along with number of request and message notification on the website header ?

    I have hidden the wordpress bar for non-admin user so they have no quick access to the notification unless they visit the their profile page.

    I would like have this notification visible to signed in members so they can see the number of request right from the header.

    Thank you veyr much

    Georgio
    Participant

    Hi @mcuk
    The bubble works well, thank you very much!
    Here is a screenshot

    As you see, I put the notification link (Appearance>Menus) on the menubar and I added the bubble with negative left margin (-5 px) for the two elements to be near each other. So if a user has a notification, they can click the notification link (notif) directly to see it.

    Thanks again!

    @mcuk
    Participant

    Hi @aminipix,

    This css should work:

    #footer-menu ul li.bubble {
        transform: translate(0, 20%);
        min-width: 22px;
        height: 22px;
        padding: 4px;
        border: 1px solid #000;
        border-radius: 50%;
        margin: 0 10px 0 0;
        background: #fff;
        color: #000;
        font-size: 11px;
        line-height: normal;
        text-align: center;
    }

    The problem seemed to be mainly caused by the line-height properties of your .tab class which is also being used by the text in your bubble. If you use the F12 button and locate the line ul id="menu-app-footer" class="footer-menu tabs tabs-icon-top" (its just above where the bubble is), then scroll down the Styles window to the .tabs selector, you will see what i mean about the line-height (set to be 49px).

    The php code shows the notification count for the logged in user, so check that what is being displayed for a user is actually the correct number of notifications. If viewing the profile page of another user for example, the numbers will stay the same since the logged in user is the same. If the numbers are changing, then maybe there is a conflict with another function or plugin. As for when you are logged out, do you even need to see the notification bubbles? If not then maybe just prevent them being visible from anyone who is not logged in.

    #252390
    Dono12
    Participant

    No, the plugin is not online. I built it with bits of code and tuts across the web about customizing WordPress notification emails. if you can send me an email address (please black this out **** (removed at users request ~hnla)) I can send you the plugin and you look it over. I saw on the web that you should remove filter after applying it but it didn’t seem to have any affect.

    remove_filter( 'wp_mail_content_type','mycustom_mail_content_type' );

    wpmirwin
    Participant

    Hi all (hoping that @djpaul notices this),

    Email trouble in BP is apperantly very hard to solve (I’ve been sifting through email related posts in the forums for hours!), so I’m going to include as many clues here as possible. Hopefully someone has the patience to read all this and make sense of it, and hopefully this problem is not specific to my installation. Yes, I have a lot of plugins. But, I have disabled all of them at times to test this, and I’m fairly confident that it is not a plugin conflict.

    Problem Summary:

    It seems like some of the messages generated by BP are formed in such a way that they are being rejected (silently?) by external mail servers (i.e. google, yahoo, hotmail) while other email messages are fine. I think this may be giving the impression that BP is not sending the email, but the email messages are in fact being sent (in my case anyway). They just don’t seem to be handled properly on the recieving end. Why?… I have no idea. Hoping for some tips to continue troubleshooting here.

    Product Versions

    WP: v4.4.2
    BP: v2.5.2

    Relevant Plugins in use:

    wp-mail-smtp: In case the email problems were PHP mail() related
    bp-email-to-wp-mail-from-bridge: To fix BP ignoring existing mapping for the From email
    buddypress-group-email-subscription: To add group email functionality (mentioning only because email sent from this plugin works fine – plain text)

    Relevant Config Info:

    At first I wasn’t using an SMTP plugin, but my current config is using WP-Mail-SMTP.
    It is configured with the localhost as the SMTP Server (HostGator shared host).
    Outoing email seems to work fine (with or without the plugin). It’s only outgoing BP mail that isn’t working properly.

    High Level Details:

    Some BuddyPress generated email works and some doesn’t. There are 3 specific examples that I’ve been testing:

    * The “Friend Request” email works great! It’s a really nice HTML formatted email that informs the target of the request that the request has been made.
    * A PM to a member doesn’t work. No email notification is sent to the target of the PM (Notification settings are correct)
    * A Mention doesn’t work. No email is sent to the BP user targeted by the mention (Notification settings are correct).

    The email messages that don’t appear to be working (i.e. not reaching it’s destination) are actually being sent. However, it seems like they are completely ignored by the receiving mail server.

    * This has been confirmed with the debug plugin (bp-email-debug-2.php). In all cases it reports that the email was sent.
    * This has been confirmed by my ISP. I had them watch the email get sent out from the localhost (the smtp server) to a google mail server (for example) but the message was not received.

    I know that my mail server/domain is not blacklisted because as mentioned above, the “Friend Request” email is sucesfully sent and delivered to the same recipeint. Also, the buddypress-group-email-subscription plugin works well and sends email succesfully to the same recipients.

    NOTE:The same email (eg. PM and Metion related email) that is not delivered successfuly to external mail servers (google, yahoo, hotmail) IS sucessfully delivered to email addresses hosted on my local mail server (i.e. the mail server running on the same WP/BP host – Hostgator).

    Some steps I’ve taken to test/resolve

    I’ve ensured that the “From” email address is correct (i.e. not being rejected because it is “wordpress@domain.com”). BTW, this led me to the bp-email-to-wp-mail-from-bridge Plugin which bridges wp_mail_from settings that I had in WP functions.php (child theme) to BP Email fuction(s). Everything is fine here.

    I’ve installed and tested WP-Mail-SMTP plugin in every way I can imagine. No change in email behaviour

    I made sure all available options in the notification settings (i.e. to receive all types of notifications) are enabled and have tested the various email scenarios on many different users.

    Other important notes

    I’m using the plugin buddypress-group-email-subscription to send email to group members when things happen in the forums. As mentioned above, this plugin successfully sends email to the same recipeints that are not recieving the PM and Metnion emails. Worth noting is the email messages sent by this plugin are plain text.

    Finally

    Thanks for getting this far… that’s a lot of reading. Sorry. I’m not expecting a simple answer to this. I’m just hoping for someone to point me in the right troubleshooting direction.
    <br><br>

    jasonaring42
    Participant

    Woohoo! @berkelmudez excellent find!…….I have been working on this problem for three days and you are right; any combo of other SMTP plugins with various other mailing plugins etc. just did not work. Postman SMTP plugin suggests the proper port to use (of which I tried prior, but had everything else wrong!) and fixed all notifications.

    Note for others having this same problem: My system would only send out certain notifications regarding signups and email changes but anything dealing with activity in the BuddyPress system (why we USE BuddyPress!) it would not notify users of activity. Try the Postman SMTP plugin and get rid of the other stuff.

    #251943
    Angelo Rocha
    Participant

    Is possible insert a notification to specific user using php?
    Eg.:
    bbpress_insert_notification($user_id, $content_notification);

    Kieran
    Participant

    I’m looking to set up moderation through my BuddyPress install. I’ve looked at the permissions and no matter what I try I seem to come up empty handed – any thoughts on what permissions I would give to a user to allow them to delete others activity from the front end. I will have my site set up in such a way that the user (any level other than super admin) cannot see the back end.

    Further, I have set up a user called flag, (I have hidden flag from being visible anywhere on the site, and when a user attempts to go to the URL they’re forwarded to the support page I have setup) I wish to have their notifications forwarded to anyone who has X role or to a set of user ID’s that can delete said post if it offends.

    I used the above code to achieve the hidden user https://buddypress.org/support/topic/hide-admin-from-members-and-activity/#post-190874

    Does anyone have any thoughts on this? I’m pretty stuck.

    Thanks,

    Kieran

    #251744
    davidkey772
    Participant

    Yes, the issue has been there since day one – and I searched for plugins to add this functionality but couldn’t find one that worked. Then I saw the new BP update with the added BP Email functionality and I realised that a/. this functionality indeed hadn’t been there before and b/. it had now been officially added as a part of BP’s core code.

    The plugin that sends new blog post notifications is:
    =
    Post Notification by Email
    Version 4.1.2 | By Valerio Souza, Claudio Sanches
    =

    Here’s a list of ALL the plugins on the site:
    =
    Advanced Custom Fields Pro
    Version 5.3.2.2 | By elliot condon

    BP Group Activities Notifier
    Version 1.0.1 | By Brajesh Singh(BuddyDev)

    BP Group Hierarchy
    Version 1.4.3 | By David Dean

    BP Groupblog
    Version 1.8.12 | By Rodney Blevins, Marius Ooms, Boone Gorges

    BuddyPress
    Version 2.5.1 | By The BuddyPress Community

    BuddyPress Forum Editor
    Version 1.0 | By Taehan Lee

    BuddyPress Groups Import
    Version 0.1 | By Türker YILDIRIM

    Email Users
    Version 4.8.1 | By Mike Walsh & MarvinLabs

    Gravity Forms
    Version 1.9.17.5 | By rocketgenius

    Gravity Forms + Custom Post Types
    Version 3.1.1 | By David Smith

    Gravity Forms WYSIWYG
    Version 0.2 beta | By Brad Vincent

    Jetpack by WordPress.com
    Version 3.9.4 | By Automattic

    Post Notification by Email
    Version 4.1.2 | By Valerio Souza, Claudio Sanches

    SB Welcome Email Editor
    Version 4.8 | By Sean Barton
    =

    ds123
    Participant

    thanks for the reply its a themeforest theme called vivacity and here are the plugins i have installed:

    Akismet
    Version 3.1.8 | By Automattic | View details

    Audio player
    Version 2.0.4.1 | By Martin Laine | Visit plugin site

    Auto Post Thumbnail
    Version 3.3.4 | By Aditya Mooley , Tarique Sani | View details

    BuddyPress
    Version 2.5.1 | By The BuddyPress Community | View details

    CloudFlare
    Version 1.3.20 | By Ian Pye, Jerome Chen, James Greene, Simon Moore, David Fritsch, John Wineman

    Dashboard Widget Remover
    Version 1.0 | By Zihad Tarafdar | View details

    Disable wp new user notification
    Version 0.100323 | By Corey Salzano | View details

    Google Analytics by Yoast
    Version 5.4.6 | By Team Yoast | View details

    LayerSlider WP
    Deactivate | Edit
    Version 5.6.2 | By Kreatura Media | Visit plugin site

    Log Report Plugin
    Keeps Stop Spammer logs in CSV file
    Version 1.0 | By Keith P. Graham | Visit plugin site

    Mail From
    Version 1.0.1 | By Andrew Hamilton | View details

    Select SI CAPTCHA Anti-Spam
    Version 2.7.7.7 | By Mike Challis | View details

    Stop Spammers Spam Control
    Version 6.15 | By Keith P. Graham | View details

    Vivacity Plugin
    Version 1.2 | By GhostPool

    WP Maintenance Mode
    Version 2.0.3 | By Designmodo | View details

    WP Super Cache
    Version 1.4.8 | By Automattic | View details

    WP Widget Cache
    Version 0.26 | By Andrew Zhang | Visit plugin site

    WPBakery Visual Composer
    Version 4.9 | By Michael M – WPBakery.com | Visit plugin site

    Yoast SEO

    #251481

    In reply to: Display notifications

    neijisly
    Participant

    Ok go in editor theme, click in header.php and try to ad this code just before </nav><!– #site-navigation –>

    <?php if(bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) > 0 ) { ?>

      <#li>
      <#a href=”<?php echo bp_loggedin_user_domain() ?><?php echo BP_NOTIFICATIONS_SLUG ?>”><span style=”font-weight: bold; background: #37b5e4; padding: 2px 2px 2px 2px;”><?php echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
      ?></span> Notifications<#/a>
      <#/li>
      <?php } ?>
      <#li>
      <#a href=”<?php echo bp_loggedin_user_domain() ?><?php echo BP_MESSAGES_SLUG ?>”><?php if(messages_get_unread_count() > 0 ) { ?><span style=”font-weight: bold; background: #37b5e4; padding: 2px 2px 2px 2px;”><?php echo messages_get_unread_count();
      ?></span><?php } ?> Messages<#/a>
      <#/li>
      <#/ul>
      ( please delete all # symbol in this code )
    #251477

    In reply to: Display notifications

    neijisly
    Participant

    Here is the code

    <?php if(bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) > 0 ) { ?>
    <~li>
    <~a><?php echo BP_NOTIFICATIONS_SLUG ?>”>
    <?php echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
    ?> Notifications</~a>
    </li~>
    <?php } ?>
    <~li>
    <~a><?php echo BP_MESSAGES_SLUG ?>”><?php if(messages_get_unread_count() > 0 ) { ?>
    <?php echo messages_get_unread_count();
    ?>
    <?php } ?> Messages<~/a>
    <~/li>

    put in your php menu file
    ( delete all ~ in the code )

    pattz2016
    Participant

    i want to be the only one able to view the link as the admin. When users are viewing their notifications in the right side, there are links to WordPress.org on the left side. I don’t think this part is relevant to my users based on the forums they are discussing.

    Any advise Please?

    jemmatates
    Participant

    I’m using <?php bp_get_loggedin_user_nav(); ?>

    but it is only showing the message count inside the members profile, is there any code i can put in the bp-custom file to also show the message count outside of the users profile url?

    The other notification counts for other menu items work sitewide, only messages is missing. Any help would be greatly appreciated!!

    @mcuk
    Participant

    Hi @mikee1001,

    The code i used for inserting the bubble counters for notifications, unread messages and total friends is:

    // Notification counter bubble
    function bptest_main_nav_notification_bubble( $items, $args ) {
        if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus
        	$items_array = array();
            while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) {
                $items_array[] = substr( $items, 0, $item_pos );
                $items = substr( $items, $item_pos );
            }
            $items_array[] = $items;
            array_splice( $items_array, 3, 0, '<li class="bubble">' . bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc
            $items = implode( '', $items_array );
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'bptest_main_nav_notification_bubble', 10, 2 );
    // Unread message counter bubble 
    function bptest_main_nav_message_bubble( $items, $args ) {
        if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus
            $items_array = array();
            while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) {
                $items_array[] = substr( $items, 0, $item_pos );
                $items = substr( $items, $item_pos );
            }
            $items_array[] = $items;
            array_splice( $items_array, 5, 0, '<li class="bubble">' . bp_get_total_unread_messages_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc
            $items = implode( '', $items_array );
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'bptest_main_nav_message_bubble', 10, 2 );
    // Total friends counter bubble
    // Note, 'bp_friend_get_total_requests_count' will give the total connection request count if desired
    function bptest_main_nav_friend_bubble( $items, $args ) {
        if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus
            $items_array = array();
            while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) {
                $items_array[] = substr( $items, 0, $item_pos );
                $items = substr( $items, $item_pos );
            }
            $items_array[] = $items;
    		array_splice( $items_array, 7, 0, '<li class="bubble">' . friends_get_total_friend_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc
            $items = implode( '', $items_array );
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'bptest_main_nav_friend_bubble', 10, 2 );

    In each of the above you will want to change the theme_location == 'header-menu' to theme_location == 'INSERT YOUR HEADER MENU NAME HERE'. The name of your menu is found via your WP Dashboard > Appearance > Menus. The three functions above were inserted into bp-custom.php .

    The positions of the bubbles will also need changing depending on where they should be in your menu. Do that by changing the numbers on the section array_splice( $items_array, 7, 0, '<li class="bubble">'. The comment alongside the line in the code should help you.

    You’ll also need some CSS for the bubbles otherwise you probably won’t see them even if they are functioning. If you hit ctrl-A to select everything on your web page, they should show up somewhere in your menu (assuming the code has been implemented correctly of course).

    As you can see in the functions above all the bubbles have been given a class called “bubble”. So put in your style.css (of your child theme) something like:

    #main-navigation .main-nav ul li.bubble {
    	transform: translate(0, 50%);
    	width: 20px;
    	height: 20px;	
    	padding: 2px 6px; 
    	border: 1px solid #000;
    	border-radius: 50%;
    	margin: 0 10px 0 0;
    	background: #fff;
    	color: #000;
    	font-size: 11px;	
    }

    The selector (#main-navigation .main-nav ul li.bubble) may be different on your site because it will depend on your theme etc. So use the developer tools, F12 button, on your browser to find out the correct one. It will be the bit before the .bubble that is different.

    Hopefully the above helps!

    #249391

    In reply to: queries on posting

    Slava Abakumov
    Moderator
Viewing 25 results - 326 through 350 (of 772 total)
Skip to toolbar