Search Results for 'notification user id'
-
AuthorSearch Results
-
July 20, 2015 at 7:11 pm #242048
In reply to: Get Post ID from Notification
creativesinsideParticipantIs this what you were looking for?
object(BP_Notifications_Notification)#394 (8) { ["id"]=> string(26) "bp_get_the_notification_id" ["item_id"]=> NULL ["secondary_item_id"]=> NULL ["user_id"]=> NULL ["component_name"]=> NULL ["component_action"]=> NULL ["date_notified"]=> NULL ["is_new"]=> NULL }
July 20, 2015 at 6:05 pm #242042In reply to: Get Post ID from Notification
creativesinsideParticipantAck my bad! I’m fairly new to php and super new to Buddypress.
Ok soooo … in the file notifications-loop.php inside the loop I’ve added:
$notificationid7 = bp_get_the_notification_id(); $obj = bp_notifications_get_notification( $notificationid7 );
And where I need to display the link (also in notifications-loop.php):
<a href="/pins/<?php echo $obj->item_id; ?>">view</a>
Lastly, where I passed the item ID in bp-notifications-functions.php:
function bp_notifications_add_notification( $args = array() ) { $r = wp_parse_args( $args, array( 'user_id' => 0, 'item_id' => $post_id, 'secondary_item_id' => 0,
However it’s echoing the notification number … not the post ID.
July 19, 2015 at 9:17 pm #242012In reply to: Get Post ID from Notification
creativesinsideParticipantThis is my code:
<?php while ( bp_the_notifications() ) : bp_the_notification(); $user_id = $bp->notifications->query_loop->notification->secondary_item_id; //bp_notifications_mark_notification(bp_get_the_notification_id(),false); ?>
<?php $messageId = buddypress()->notifications->query_loop->notification->item_id; $message = messages_get_message($messageId); $image = null; if ($message) { $title = apply_filters( 'bp_get_message_thread_from', bp_core_get_userlink( $message->sender_id ) ); if ($message->subject == "comment on your post") { $title .= " commented on your post"; } elseif ($message->subject == "like your post") { $title .= " liked your post"; } else { $title = null; } $image = bp_messages_get_meta($messageId, 'images'); $obj = bp_notifications_get_notification( $id ); } ?>
And the echo:
<div><a href="/pins/<?php echo $obj->item_id; ?>">VIEW</a></div>
July 19, 2015 at 8:42 pm #242010In reply to: Get Post ID from Notification
creativesinsideParticipantIs this the proper way to have it setup at the function?
function bp_notifications_add_notification( $args = array() ) { $r = wp_parse_args( $args, array( 'user_id' => 0, 'item_id' => $post_id, 'secondary_item_id' => ,
July 19, 2015 at 5:40 pm #242004In reply to: Get Post ID from Notification
creativesinsideParticipantCan I simply add post_id into this?
function bp_notifications_add_notification( $args = array() ) { $r = wp_parse_args( $args, array( 'user_id' => 0, 'item_id' => 0, 'secondary_item_id' => 0, 'component_name' => '', 'component_action' => '', 'date_notified' => bp_core_current_time(), 'is_new' => 1, 'allow_duplicate' => false, ) ); // Check for existing duplicate notifications if ( ! $r['allow_duplicate'] ) { // date_notified, allow_duplicate don't count toward // duplicate status $existing = BP_Notifications_Notification::get( array( 'user_id' => $r['user_id'], 'item_id' => $r['item_id'], 'secondary_item_id' => $r['secondary_item_id'], 'component_name' => $r['component_name'], 'component_action' => $r['component_action'], 'is_new' => $r['is_new'], ) ); if ( ! empty( $existing ) ) { return false; } } // Setup the new notification $notification = new BP_Notifications_Notification; $notification->user_id = $r['user_id']; $notification->item_id = $r['item_id']; $notification->secondary_item_id = $r['secondary_item_id']; $notification->component_name = $r['component_name']; $notification->component_action = $r['component_action']; $notification->date_notified = $r['date_notified']; $notification->is_new = $r['is_new']; // Save the new notification return $notification->save(); }
June 24, 2015 at 10:51 am #241042In reply to: Custom Post Type Support for Activity
milenushkaParticipantHi @imath, thank you so much for writing back. For some reason I didn’t get the notification, and was depressed over the site for a month. Today I decided to finally face the issue again, and what a nice surprise!
So my code is:
add_filter( 'bp_blogs_record_post_post_types', 'inspired_record_more_types' ); function inspired_record_more_types( $types ) { $types[] = 'projects'; $types[] = 'sfwd-courses'; $types[] = 'uig_image'; return $types; } add_filter('bp_blogs_activity_new_post_action', 'record_cpt_activity_action', 1, 3); function record_cpt_activity_action( $activity_action, $post, $post_permalink ) { if( $post->post_type == 'projects' ) { $activity_action = sprintf( __( '%1$s created a new project, %2$s ', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); } if( $post->post_type == 'sfwd-courses' ) { $activity_action = sprintf( __( '%1$s added a new workshop, %2$s ', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); } if( $post->post_type == 'uig_image' ) { $activity_action = sprintf( __( '%1$s added a new image, %2$s ', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); } return $activity_action; } function bbg_record_my_custom_post_type_comments( $post_types ) { $post_types[] = 'projects'; return $post_types; } add_filter( 'bp_blogs_record_comment_post_types', 'bbg_record_my_custom_post_type_comments' );
Thank you so much. I really appreciate it.
June 23, 2015 at 1:27 am #240989In reply to: Chat Plugins with one-to-many messaging?
djstevebParticipant@jacipetersilie – best thing I have seen that is close to fbook like chat thing is the free “quick chat plugin” – however I do not use it to show as a widget on all pages and give a popup to users – as I think that would tax the server and web browser more than is reasonable if you have dozens of users – it might work, might not. I use quick chat for a single chat room on a single page.
From what you are describing however, I wonder if you really need a chat plugin to do what you are saying – one to many message – like the super-admin send a message to all users, kind of privately… I think there are some plugins in the wild that allow admin to send an email (Which I guess would be a buddypress inbox notification (?)) – to all users… that would “one to many” message – and give people a way to “message you back” privately I think.
I have also seen a plugin that will allow super admin to add a note to all dashboards – although I guess many bp users will not go to their dashboard when using most features –
I suppose you could also assign users to a group, and select settings for them to get a notice email when a new group message is sent. Which may achieve what you are describing.
If you just want one-to-many messaging chat with users who are actually logged into a chat room, I think it would be easy to do that with nusoft’s av-chat, there are settings in which you can make it so only certain users can post in the chat, have moderated chat, turn off pms and stuff like that – I guess I am not clear on what exactly you are trying to accomplish as I don’t use fbook and am not familiar with the kind of one to many fbook messaging you are talking about.
May 31, 2015 at 1:12 am #239939In reply to: [Resolved] BP CSS Classes Locked in Menu Dashboard
OsisisParticipantNot sure how to mark this topic resolved, but I’ve decided to go about this in another manner. I followed the BP model and have my admin bar acting in the capacity of a menu and deleted my primary menu. Is working out pretty well thus far. For anyone else that’s interested I
Removed “howdy, $name” just because to me it screams WP
function custom_adminbar_welcome() { global $wp_admin_bar; $name = wp_get_current_user()->display_name; $avatar = get_avatar( wp_get_current_user()->ID, 28 ); $class = $class = empty( $avatar ) ? '' : 'with-avatar'; $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => __('') . $avatar, 'class' => $class ) ); } add_action( 'wp_before_admin_bar_render', 'custom_adminbar_welcome' );
Removed WP links and change logo
add_action( 'wp_before_admin_bar_render', 'custom_adminbar_welcome' ); function rebranding_wordpress_logo(){ global $wp_admin_bar; //the following codes is to remove sub menu $wp_admin_bar->remove_menu('about'); // Remove the about WordPress link $wp_admin_bar->remove_menu('wporg'); // Remove the WordPress.org link $wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link $wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link $wp_admin_bar->remove_menu('feedback'); // Remove the feedback link $wp_admin_bar->remove_menu('site-name'); // Remove the site name menu $wp_admin_bar->remove_menu('view-site'); // Remove the view site link $wp_admin_bar->remove_menu('updates'); // Remove the updates link $wp_admin_bar->remove_menu('comments'); // Remove the comments link $wp_admin_bar->remove_menu('new-content'); // Remove the content link $wp_admin_bar->remove_menu('w3tc'); // If you use w3 total cache remove the performance link //and this is to change wordpress logo $wp_admin_bar->add_menu( array( 'id' => 'wp-logo', 'title' => '<img src="http://test.theblackxperience.com/darklogo45.png" />', 'href' => __(home_url()), 'meta' => array( 'title' => __('eQubator'), ), ) ); } add_action('wp_before_admin_bar_render', 'rebranding_wordpress_logo' );
Moved BP child menus up to make them primary menus
function make_parent_node( $wp_admin_bar ) { if ( ! is_user_logged_in() ) { return false; } $wp_admin_bar->add_node( array( 'id' => 'my-account-activity', // id of the existing child node (New > Post) 'title' => '<span class="ab-icon"></span><span class="ab-item">'._x( '', '' ).'</span>', // alter the title of existing node 'parent' => false, // set parent to false to make it a top level (parent) node )); $wp_admin_bar->add_node( array( 'id' => 'my-account-friends', // id of the existing child node (New > Post) 'title' => '<span class="ab-icon"></span><span class="ab-item">'._x( '', '' ).'</span>', // alter the title of existing node 'parent' => false, // set parent to false to make it a top level (parent) node )); $wp_admin_bar->add_node( array( 'id' => 'my-account-messages', // id of the existing child node (New > Post) 'title' => '<span class="ab-icon"></span><span class="ab-item">'._x( '', '' ).'</span>', // alter the title of existing node 'parent' => false, // set parent to false to make it a top level (parent) node )); $wp_admin_bar->add_node( $args ); } add_action( 'admin_bar_menu', 'make_parent_node', 999 );
Added CSS to turn the menu items into dashicons
#wp-admin-bar-my-account-friends .ab-icon:before{ font-family: "dashicons" !important; content: "\f307" !important; } #wp-admin-bar-my-account-messages .ab-icon:before{ font-family: "dashicons" !important; content: "\f466" !important; } #wp-admin-bar-my-account-activity .ab-icon:before{ font-family: "dashicons" !important; content: "\f130" !important; } #wpadminbar .quicklinks li#wp-admin-bar-bp-notifications>a:before{ font-family: "dashicons" !important; content: "\f319" !important; }
Only problem I’m having now is that for some reason the logo has decided to move itself to the right, but that’s another question for another topic. But hope this helps someone else.
May 27, 2015 at 2:31 pm #239743@mcukParticipantThese might help you @antoinegdln4:
[Resolved] Position Notification Counter Bubble after Specific Navigation Tab ID
https://buddypress.org/support/topic/help-customising-admin-bar-removing-links-from-dropdown/
or removing WP admin bar entirely to all users except admin:
function remove_admin_bar() { if ( !current_user_can( 'administrator' ) && !is_super_admin() ) { show_admin_bar(false); } } add_action( 'after_setup_theme', 'remove_admin_bar' );
May 27, 2015 at 2:10 pm #239742@mcukParticipantHey @osisis,
Glad to see you sorted it. This was my code:
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 id="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 );
I gave it the ID ‘bubble’. You can obviously give it a class if you want too (class=”bubbles”).
May 3, 2015 at 11:12 pm #238656danbpParticipantTwo snippets to do this (hopefully). The first has a fixed position (latest by default), the second let’s you choose the position.
function my_nav_menu_notif_counter($menu) { if (!is_user_logged_in()) return $menu; else $notif = '<li>Notif '. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</li>'; $menu = $menu . $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter' );
See comment how to apply a position function my_nav_menu_positioned_notif_counter( $items, $args ) { if( $args->theme_location == 'primary' ) // only for primary menu { $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, 0, 0, '<li>Notif '. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</li>'); // 0,0 is first position, 1,0 is second, etc $items = implode('', $items_array); } return $items; } add_filter('wp_nav_menu_items','my_nav_menu_positioned_notif_counter', 10, 2);
Reference: https://developer.wordpress.org/reference/hooks/wp_nav_menu_items/
May 3, 2015 at 9:39 pm #238655@mcukParticipantAll the code I’ve used is in the post above. Not required any custom functions.
The function:
bp_notifications_get_unread_notification_count( bp_loggedin_user_id() )
was mentioned here:https://buddypress.org/support/topic/how-to-get-notification-count-code/
Just echoing that function in my child header.php gives me exactly what i needed (along with the CSS i posted). Everything works fine.
The only issue is to locate it within the menu itself in the correct location after the Notification tab, which i cannot do in the header file. At the moment I am only able to locate it within the container that holds the menu.
The menu I am using I have created via WP > Appearance > Menus. Just a bog standard menu in the header of the page.
May 3, 2015 at 8:08 pm #238650@mcukParticipantHi all,
I am trying to insert a notification counter bubble within my main navigation menu after one specific ‘menu item li id’. Using the code below I have managed to display the counter correctly on the page but am unable to work out how to place it where I want after the desired menu item. Can anyone offer any pointers?
I already have the code to display the notification counter:
echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
I then added it to my theme’s child header.php within the main menu container div and gave it it’s own div & id to enable styling:
<div id="testid"><?php echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ); ?></div>
(Putting it here was just a test to see if the echo and CSS were correct).
The CSS which makes it appear correctly:
#testid { background: #eee; border-radius: 50%; border: 1px solid #ccc; color: #000; display: inline; font-size: 70%; margin-left: 2px; padding: 3px 6px; text-align: center; vertical-align: middle; }
I ran a search for ‘notification counter’ along with a few other things but didn’t come across a recognisable solution.
Thanks
April 15, 2015 at 7:36 am #237902In reply to: Chat plugin?
djstevebParticipantSo what op is saying, is that basically taking the notifications from the top right and putting “inbox notifications” on the bottom right of the screen, and when hover / clicked would bring up latest messages, and instead of clicking those bring you to a new bp page, it could ajax load your private messages – and allow for image uploads.. would kind of do what you are talking about.. no fancy chat required.. kind of I guess?
I use quick chat on one site with a dedicated server, and only enable it to work on one page, not show up on every page of the site.. I use av-chat (from nusoft I think) on a busier site.. but with my sites I am not using them in the way the OP is asking about, a mini chat tab on each page.. I just use them as chat rooms on a single page.
Tried many other solutions, paid for many, most fail miserably starting around 20 users.
/random thoughts at 2am
April 6, 2015 at 9:57 am #237321In reply to: forum and group notification
danbpParticipanthi @dingxiaohan,
default general usage of notification is explained on our Codex:
https://codex.buddypress.org/member-guide/notifications/Each topic can be followed by the author and all who answer on a per topic base. Email you’ll receive in this case will show the topic url and a brief excerpt.
A little different is BP Live Notification plugin, which add a Facebook Like real-time notification for user.
Some other way to use and show notification can be done by coding a little, which is explaine here.
April 5, 2015 at 7:48 am #237299In reply to: turn off email notifictions in functions.php
5highParticipantBrilliant! It worked a treat, and I used the ‘user_register’ as suggested. So for anyone else looking for this solution, this is the code i used to turn some on and some off by default on new user registration:
add_action( 'user_register', 'bpdev_set_email_notifications_preference'); function bpdev_set_email_notifications_preference( $user_id ) { //I am putting some notifications to no by default and the common ones to yes to enable it. //ref. https://bp-tricks.com/snippets/changing-default-buddypress-notifications-settings and BP forum $settings_keys = array( 'notification_activity_new_mention' => 'yes', 'notification_activity_new_reply' => 'yes', 'notification_friends_friendship_request' => 'no', 'notification_friends_friendship_accepted' => 'no', 'notification_groups_invite' => 'no', 'notification_groups_group_updated' => 'no', 'notification_groups_admin_promotion' => 'no', 'notification_groups_membership_request' => 'no', 'notification_messages_new_message' => 'yes', ); foreach( $settings_keys as $setting => $preference ) { bp_update_user_meta( $user_id, $setting, $preference ); } }
and this went in my child theme functions.php file.
Hooray! Thanks so much again – it will make a big different to our users experience.
Cheers 🙂March 31, 2015 at 1:41 pm #237014In reply to: Displaying Notifications Tab out of admin bar
mrgibletsParticipantI should add that i’ve got a part of it working by echoing the following where I want it to appear but it’s obviously just echoing the numerical count and I want the full functionality of the BP notification tab with links and descriptions of the items.
echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
March 30, 2015 at 2:22 am #236912mcpeanutParticipant@henrywright YOU MY FRIEND ARE A STAR! 🙂 This is exactly what i was looking for and can confirm its working for me, i have now got the mentions split out with the number of mentions displayed and working correctly, thankyou very much henry!!!! also thankyou very much @danbp for your help. This is resolved! cheers.
Oh one last thing henry it turns out i didnt need to use the echo $count; at the end because it was causing it to echo 4 times on the page, but removing it seemed to fix the problem and the count is still showing.
So the final code i used was
$query_vars = array( 'user_id' => get_current_user_id(), 'component_action' => 'new_at_mention', 'is_new' => true ); $count = BP_Notifications_Notification::get_total_count( $query_vars )
ty once again henry.
March 29, 2015 at 6:32 pm #236889Henry WrightModeratorHey again @mcpeanut,
I’ve had a little bit more time this evening to look at this for you. I found that the notifications component provides a public static method
get_total_count()
which can be used to get the unseen mention count. You can use it like this:$query_vars = array( 'user_id' => get_current_user_id(), 'component_action' => 'new_at_mention', 'is_new' => true ); $count = BP_Notifications_Notification::get_total_count( $query_vars ); echo $count;
Hope that does the trick!
March 29, 2015 at 1:42 pm #236851mcpeanutParticipant@henrywright using this bp_activity_format_notifications( $user_id = 0 ); i have got the mentions to show in the dropdown but without the username of who mentioned you until you hover over it, there is no count though.
March 28, 2015 at 12:11 am #236799In reply to: turn off email notifictions in functions.php
5highParticipantUpdate:
well i’ve just tested option #1 and it didn’t work – my test new user had all email notifications still set to ON as the default.
and # 2 code didn’t work either – all set to ON.
Maybe @henrywright or @nd1 could throw some light on this if possible, as their thread is now closed??
Or any other ideas would be much appreciated – thanks heaps.
March 27, 2015 at 11:30 pm #236797mcpeanutParticipantI have been customizing the way my notifications are shown and have split them out from the main notifications bubble, so far i have managed to do this via these hooks/filters
bp_friend_get_total_requests_count
bp_notifications_get_unread_notification_count
messages_get_unread_countNow i don’t know the ones that relate specifically to the comment notifications a user receives when someone replies or comments on their status update etc, any ideas?
March 27, 2015 at 7:07 am #2367415highParticipantBack again, after just completing the above edits and BINGO! it works! But only because i followed your very clear step-by-step instructions above. Thank you @danbp and @hnla for your help and support – Only possible by the ‘paint by numbers’ approach for me at present!
I presume that if i want to ‘hide a couple of other things in a user’s profile section I could do it the same way (just don’t know where of course!)? Both are in a user’s profile > Settings; one is the ‘Profile Visibilty’ tab and the other is the bottom section of the ‘Email’ notifications tab, which shows the Groups email notifications options (as I’ve set them all to default as off for new users, via my functions.php).
But I’m happy to start a new thread for this as it might be better for others to follow?
Cheers.
March 26, 2015 at 10:51 pm #236699In reply to: Double entries
bluedawgParticipantInterestingly when I set up users myself abd registered them I only get one email notification that a new user has registered. but when others register I get a double notification. See attached screengrab. Could they be spammers?
Also on the activity page there is a double entry of their join date with one being squished off to the right side… also see attached screen grab:
March 26, 2015 at 8:44 am #236652In reply to: No Notifications For Mentions In Comments
danbpParticipantPost comments are outside of the user notification. @mention scope is handling site and user activities. A post is also an activity, but @mention in it is not an activity. It’s just a link to a profile in a post.
When you go to message settings on your profile, you can see the whole items covered by mention and email notification. Blog post are not included.
-
AuthorSearch Results