Search Results for 'notification user id'
-
AuthorSearch Results
-
December 15, 2015 at 12:32 pm #247776AntonioParticipant
Hi Henry and r-a-y, I have the same request and I have to thank you for the replies.
Specifically I would add a notification when a user read a received message, so i guess whene a message (or thread?) is marked as read.
If I have to use these functions and hook as well, I understand how to use them, the only thing that I don’t know is how to get IDs. For example when I perform
bp_after_message_thread_content
, in the function that I call, how can I get the id of the thread? Adter I gues I have to get the id of the last message of that thread for change its meta, how can I get that id?Please give me some suggestions and let me know if there are better ways for this.
Sorry for my poor english.December 9, 2015 at 4:11 pm #247589In reply to: Hide count – please help a PHP newbie
shanebpModeratorif ( bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) != 0 ) $notif .= '<li class="notify"><a href=" ' .$notif_url. ' ">Notifications <div class="notifynumber topnavcount">'. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ).'</div></a></li>'; else $notif .= '<li class="notify"><a href=" ' .$notif_url. ' ">Notifications</a></li>';
December 9, 2015 at 2:29 pm #247583In reply to: Hide count – please help a PHP newbie
shanebpModeratorTry:
function my_counter_nav_menu($menu) { $notif_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'notifications/'; $friends_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'friends/'; $msg_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'messages/'; if (!is_user_logged_in()) return $menu; $notif = '<li class="notify"><a href=" ' .$friends_url. ' ">Connections <div class="friendnumber topnavcount">'.friends_get_friend_count_for_user( bp_loggedin_user_id() ) .'</div></a></li>'; if ( bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) != 0 ) $notif .= '<li class="notify"><a href=" ' .$notif_url. ' ">Notifications <div class="notifynumber topnavcount">'. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ).'</div></a></li>'; if ( bp_get_total_unread_messages_count( bp_loggedin_user_id() ) != 0 ) $notif .= '<li class="notify"><a href=" ' .$msg_url. ' ">Messages <div class="messagenumber topnavcount">'.bp_get_total_unread_messages_count( bp_loggedin_user_id() ) .'</div></a></li>'; $menu .= $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_counter_nav_menu' );
November 29, 2015 at 7:31 pm #247266Henry WrightModeratorIs there a table in the DB that deals specifically with notifications?
Yes. That’d be
bp_notifications
If so, I guess I could just empty it before I emptied the stream and stream meta tables.
Shout up if anyone thinks that could be a problem.
Instead of deleting directly from the database, you should use these functions:
bp_notifications_delete_notifications_by_type()
bp_notifications_delete_notifications_by_item_id()
bp_notifications_delete_all_notifications_by_type()
bp_notifications_delete_notifications_from_user()
Alternatively, if none of these quite suit your need, go straight for the class method:
BP_Notifications_Notification::delete()
October 18, 2015 at 12:01 pm #245639In reply to: Can I @everyone when I message?
Henry WrightModeratorOne additional feature I was thinking about, a bit of a leap, would be that ability of the user to configure their own user group to send mentions to, a subset of their friends that they may wish to send shouts to.
Setting up arbitrary groups of members is a good idea, but I think that functionality should belong in a separate plugin. This plugin just hooks into existing collections of users such as friends, mods, group members etc.
Also, currently the notification message includes the text @group, I was wondering about removing this to enable to nicer formatting for the message.
The notification text can be localised using a language file. See the Customizing Labels, Messages, and URLs article for info on how you can do that.
October 5, 2015 at 1:39 pm #245073In reply to: Logged in Links
WebitseoParticipant@shanebp: I don’t understand. Why are all the BP pages listed as options for only logged in users in the Menu widget except for the Members page (and Register and Log in, ofcourse)? I only want logged in members to see the member directory, for the sake of the privacy of my members. I can add the page via the regular pages menu, but then it is visible in the menu to everyone even if they are logged out. Or if I go to http://www.site.com/members/ when not logged in, the page with the list of members is visible. I would like the members directory to be private. I don’t understand why BP left this out of the menu for logged in users only. If this is not possible, is there a way to block the /members/ page from the public that won’t mess anything up?
In fact, I just checked all the logged-in links in a different browser that I’m not logged in to, and the members, activities, groups, friends and profile pages are ALL visible! Doesn’t that defeat the whole purpose of having a membership community that requires registration????? At least messages, notifications, and settings are locked. Am I missing something?
October 2, 2015 at 5:18 pm #245017cisdevParticipantHello @henrywright,
Thanks for your reply.i am working with my custom code but i am unable to do,i have try many times with my added custom code.in Notification section I want accept and reject both button functionality on notification section in place of Read|Delete action and also want same functionality like accept and reject both button working and also i want hide and remove when user accept or reject
friend request then notification should be hide or remove from notification section.Please if you have any code or solution please share.
September 30, 2015 at 6:51 pm #244944pnetParticipantFor what ever reason I did not receive the email notification for your response.
My users are showing now, I figured out what I was doing wrong.
September 10, 2015 at 8:28 pm #244254In reply to: Hide Buddypress pages from google serch.
djstevebParticipant@nithin270 – any changes you make for search spiders is going to take weeks (at minimum) before they are reflected in the search results.
I suggest doing some robots.txt additions (will list mine below) – however realize that long ago google made a decisions that even if your robots.txt says to disallow crawling something, if another page on the web links to your subpage that is blocked by robots.txt, it will still show the url in the search results – but have a description something like “this sites robots.txt prevents google from displaying description of this result”.
There has been debate about that decision, but it is what it is.
The only way to really prevent a page showing up in results is to hide it behind a password (like htpasswd) – however google does normally remove results if that page (or header info of images) includes “noindex” in the head of the page (there is a tricky way to add this to images – it was pointed out to me in the google webmaster forums)
given that bp pages like members are kind of pseudo pages, using something like yoast (currently as far as I know) – will not give you an option to add noindex, nofollow to your member pages..
you may be able to modify the code I got from wpmudev that checks “if is member page, then add meta description as…” –
( http://premium.wpmudev.org/forums/topic/bp-meta-tite-description-for-groups-and-members-pages#post-806736 )
to… also check “if is members page” – then add “meta name=”robots” content “noindex, nofollow”..
(something like that)that should remove your members pages next time google crawls your site and the crawlers send the info back to the main algo/index..
I think there is a way to log into google webmaster tools if you have claimed /verified your site and click on urls to ask the big G to remove them as well. (I have not messed with that stuff in a while )
I also suggest adding a robots.txt file similar to this:
Disallow: */activity/p/*
Disallow: /docs/
Disallow: *send-invites*
Disallow: */groups/*members*
Disallow: */groups/*media*
Disallow: *widget-title*
Disallow: *members/*activity*
Disallow: *members/*notifications*
Disallow: *members/*friends*
Disallow: *members/*groups*
Disallow: *members/*docs*
Disallow: *members/*media*
Disallow: *acpage*
Disallow: *messages*
Disallow: *friends*
Disallow: *settings*
Disallow: /*/comment-page*
Disallow: *register*
Disallow: *login*
Disallow: *profile*
Disallow: *admin*
Disallow: *includes*
Disallow: *content*to prevent some other quirky indexing issues with bp.
If your member profile stuff is sacred, then I would hunt the forums here for what others have been messing with that prevents profile info from being displayed if a user is not logged in… as there are plenty of indexing spiders that will not follow the robots.txt or robots index rules in <head> – in fact some specifically look for these things and purposely crawl and scrape stuff that is blocked –
Disclaimer: I am not an expert, not a real coder. Research these things with other sources, your situation may vary.
September 9, 2015 at 11:30 pm #244204In reply to: Logged in home page
danbpParticipantTo redirect your users to their friends activities page on login, you can use this:
function bpdev_redirect_to_profile( $redirect_to_calculated, $redirect_url_specified, $user ){ if( empty( $redirect_to_calculated ) ) $redirect_to_calculated = admin_url(); //if the user is not site admin,redirect to his/her profile $url = bp_core_get_user_domain( $user->ID ) .'activity/friends/'; if( isset( $user->ID) && ! is_super_admin( $user->ID ) ) return $url; else return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/ } add_filter( 'bp_login_redirect', 'bpdev_redirect_to_profile', 11, 3 );
Snippet source: http://buddydev.com/buddypress/buddypress-trick-redirect-users-to-their-profile-on-login/
To add a home button to the main menu, use WP’s menu builder. But this doesn’t let you add a dynamic button going to EACH user profile, only to yours. You will have to code this.
See from here how to do this:
https://buddypress.org/support/topic/how-to-get-notification-count-code/#post-244069
You need to introduce this:
$url = bp_core_get_user_domain( $user->ID ) .'activity/friends/';
September 5, 2015 at 7:29 am #244069In reply to: [Resolved] How To Get Notification Count? (Code)?
danbpParticipanthi ailyroot,
no time to sort out what you need, but see here 3 snippets using different wya to add such item to a theme main menu or custom menu, with fixed or free position… Test and take the one you need.
//fixed 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' ); //choose 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); // depending the theme, $theme_location may vary and this one use a menu ID function my_notif_link( $items, $args ) { $theme_location = 'primary';// Theme Location slug $existing_menu_item_db_id = 6; // menu id $new_menu_item_db_id = 66; // unique id number $label = 'Notificationas '. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ); $url = bp_core_get_user_domain(bp_loggedin_user_id()) .'notifications/'; if ( $theme_location !== $args->theme_location ) { return $items; } $new_links = array(); if ( is_user_logged_in() ) { // only if user is logged-in, do sub-menu link $item = array( 'title' => $label, 'menu_item_parent' => $existing_menu_item_db_id, 'ID' => 'fugit', // menu name 'db_id' => $new_menu_item_db_id, 'url' => $url, 'classes' => array( 'menu-item' ) ); $new_links[] = (object) $item; // Add the new menu item to our array unset( $item ); // in case we add more items below $index = count( $items ); // integer, the order number. // Insert the new links at the appropriate place. array_splice( $items, $index, 0, $new_links ); // 0,0 is first position, 1,0 is second, etc } return $items; } add_filter( 'wp_nav_menu_objects', 'my_notif_link', 10, 2 );
Happy testing 😉
September 5, 2015 at 3:36 am #244065In reply to: [Resolved] How To Get Notification Count? (Code)?
AilyRootParticipantHi guys
we are looking for solution to get buddypress notifications work on our theme, we know it will be shown on wordpress’s default top tool bar but we want it to show somewhere else.We are using WP 4.3 with buddypress 2.3.3, we have added these to theme’s functions.php
function bpfr_add_notification_to_page_title( $title, $original_title, $sep ) { //do not change if the user is not logged in if( ! is_user_logged_in() ) return $title; $user_id = get_current_user_id();//logged in user's id $count = bp_notifications_get_unread_notification_count( $user_id ); if( $count > 0 ) $title = sprintf( "You Have %d New Notification(s) - ", $count ); return $title; } add_filter( 'wp_title', 'bpfr_add_notification_to_page_title', 100, 3 );
then we add these to theme ‘s menu location
<?php echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ); ?>
but it is showing nothing, what is the correct steps to make this work please?
thanks
September 1, 2015 at 4:24 am #243926In reply to: Incorrect Member Profile URL in Notifications
tr1stessaParticipantHello danbp,
Sorry for my late reply. I tried testing out with the twenty fifteen theme but it won’t show the notifications. I am also not using any notifications plugin (I tried on but didn’t resolve the issue either). No other errors are being generated, all links are working except for the user profile in the notification. It seems to be automatically adding the root folder and the members folder into the URL instead of just going directly to the user profile URL. Is there anything in the notifications php that I can edit to fix this?Thanks!
TeriAugust 28, 2015 at 8:59 am #243760ctuxboyParticipantHello,
– I activate the original WP twentyfifteen-theme, and i see no errors in the developer console (Chrome browser)
Is this an issue? Have more people this?
Can i adding manually the private button links?This are the installed plugins:
– All In One WP Security
– Black Studio TinyMCE Widget
– Bowe Codes
– BP Registration Options
– Bp Stickers
– BuddyPress Members only
– BuddyPress
– Child Theme Configurator
– Contact Form 7
– Duplicator
– Events Manager
– FB like notification for buddypress
– Loco Translate
– Page Builder by SiteOrigin
– Peter’s Login Redirect
– Really Simple CAPTCHA
– SiteOrigin Widgets Bundle
– User Switching (deactivated for the moment!)
– WP StatisticsThe strange thing is that all the buttons showing correctly in the user profiles when nothing a friend.
(sorry for my bad english!)
August 18, 2015 at 9:01 am #243321In reply to: Need urgent help with BP notifications
chicho1969Participantokay, This is almost done, but is really rare, not everything works as it should.
First of all, this is not a pluggin, I am writing all these code in bp-functions.php in my bududdypress folder within my theme folder. (this may be my problem).
Step by step:
1st Problem setup globals is not working as it espected:define( 'BP_NOTIFIER_CELBIRTHDAY_SLUG', 'celbirthday_notifier' ); function celbirthday_notifier_setup_globals () { global $bp, $wpdb; $bp = buddypress(); $bp->celbirthday_notifier = new stdClass(); $bp->celbirthday_notifier->id = 'celbirthday_notifier'; //I asume others are not going to use this is $bp->celbirthday_notifier->slug = BP_NOTIFIER_CELBIRTHDAY_SLUG; $bp->celbirthday_notifier->notification_callback = 'celbirthday_notifier_format_notifications'; //show the notification $bp->active_components[$bp->celbirthday_notifier->id] = $bp->celbirthday_notifier->id; do_action( 'bp_setup_globals' ); }
This function is not doing nothing unless I call it directly:
celbirthday_notifier_setup_globals ();
I Know this is not the proper way, but it is the only way I found to make it run.
Does anyone know why it does not work properly?Continue with the notification:
//Format notifications function celbirthday_notifier_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { if ( 'new_birthday' === $action ) { if ( (int) $total_items > 1 ) { if ( 'string' === $format ) { $famoso_name = get_the_title( $secondary_item_id ); return apply_filters( 'celebrities_multiple_verifications_notification','Say Happybirthday to '.$famoso_name); } } else { if ( 'string' === $format ) { //falta definir $famoso_link y mas $famoso_name = get_the_title( $secondary_item_id ); return apply_filters( 'celebrities_single_verifications_notification','Say Happybirthday to '.$famoso_name); // $return = apply_filters( $filter, '<a href="' . esc_url( $famoso_link ) . '" title="birthday anounce">' . esc_html( $text ) . '</a>', (int) $total_items, $text, $famoso_link ); // $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link ); } } } do_action( 'celbirthday_notifier_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); return false; }
ok, this format function is working right, although I have to do some more work. After it, I have two more functions (mark and delete notifications) wich are also working fine.
//mark notification function celebrities_mark_screen_notifications() { global $bp; bp_notifications_mark_notifications_by_item_id( $bp->loggedin_user->id, $bp->celbirthday_notifier->id, 'new_birthday', $secondary_item_id = false, $is_new='0'); } add_action( 'bp_notifications_screen', 'celebrities_mark_screen_notifications' );
and…
function celbirthday_notifier_remove_screen_notifications() { global $bp; bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->profile->slug, 'new_birthday' ); } add_action( 'bp_notifications_screen', 'celbirthday_notifier_remove_screen_notifications' ); add_action( 'xprofile_screen_display_profile', 'celbirthday_notifier_remove_screen_notifications' );
As I say, this works fine, but a I am not sure if I need the second “add_action” (xprofile screen).
And finally, to add notification I use this code (which is not working)://Adding notification function buddypress_celebrities_add_notification() { if ( bp_is_active( 'notifications' ) ) { $fecha_act = date("Y-m-d"); $res_birth = $wpdb->get_results( "SELECT wp_best_favs.user_id, wp_postmeta.post_id FROM wp_best_favs LEFT JOIN wp_postmeta ON ( wp_postmeta.post_id = wp_best_favs.celeb_ID ) WHERE ( wp_postmeta.meta_key = 'fecha_na') AND (DAY( <code>wp_postmeta</code>.<code>meta_value</code> ) = DAY( '$fecha_act' )) AND (MONTH( <code>wp_postmeta</code>.<code>meta_value</code> ) = MONTH( '$fecha_act' )) "); $res_birth = array_filter($res_birth); $matriz = objectToArray($res_birth); //I use this function to convert objet array to simple array if(count($matriz)==0) { // está vacío } else { global $wpdb; $bp = buddypress(); $current_time = bp_core_current_time(); foreach ($matriz as $v1) { $famoso_id = $v1[post_id]; $receiver_user_id = $v1[user_id]; $args = array( 'user_id' => $receiver_user_id, 'item_id' => $famoso_id, 'secondary_item_id' => $famoso_id, 'component_name' => $bp->celbirthday_notifier->slug, 'component_action' => 'new_birthday', 'date_notified' => $current_time, 'is_new' => 1, ); bp_notifications_add_notification( $args ); } } } } do_action( 'bp_init', 'buddypress_celebrities_add_notification' );
So this is my bigger problem:
Add notifications (function buddypress_celebrities_add_notification()) is not working.
I am pretty sure this is because I am not hooking properly, but I tried so many hooks and none of it did work.
I Know the code is fine because if I comment the two first lines and the two last lines (so I run the code not as a function) the notifications are being added to database.Anyone can help me, to find a proper hook, or just pointing me in the right direction.
Thanks in advance.August 13, 2015 at 6:02 pm #243161In reply to: Need urgent help with BP notifications
chicho1969ParticipantThanks @danbp ,
I´ll try to explain you:I have a custom_post_type (celebrities). it real name is “famosos”.
BuddyPressUsers can mark any celebrity as fasvourite.
This part is working fine.
So now, I am trying to send a notification (to users that have marked as favorite certain celebriry) that “today” is that celebrity´s birthday.For that purpose, I have a SQL query that works fine and gives me an array with budypress user id and the celebritie post id. (this is also working fine)
SO I have to setup a custom notificationa that checks every day that SQL QUery to gets users and celebrities ids to notify user about today´s birthday (of their favourite celebrities)
and this is what I did at first:
define( 'BP_ACTIVITY_CELBIRTHDAY_SLUG', 'celbirthday_notifier' ); function celbirthday_notifier_setup_globals () { $bp = buddypress(); $bp->celbirthday_notifier = new stdClass(); $bp->celbirthday_notifier->id = 'celbirthday_notifier'; //I asume others are not going to use this is $bp->celbirthday_notifier->slug = BP_ACTIVITY_CELBIRTHDAY_SLUG; $bp->celbirthday_notifier->notification_callback = 'celbirthday_notifier_format_notifications'; //show the notification $bp->active_components[$bp->celbirthday_notifier->id] = $bp->celbirthday_notifier->id; do_action( 'celbirthday_notifier_setup_globals' ); } add_action( 'bp_setup_globals', 'celbirthday_notifier_setup_globals' );
and then try to format the notification:
function celbirthday_notifier_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { if ( 'new_birthday' === $action ) { $famoso_name = get_the_title( $secondary_item_id ); $subject = 'Celebrity birthday'; $message = 'Say happy birthday to $famoso_name'; $content = 'Tody is $famoso_name birthday .....somethin else '; if ( (int) $total_items > 1 ) { $text = sprintf( __( 'You have %d celebrities birthday', 'bbpress' ), (int) $total_items ); $filter = 'bp_activity_at_message_notification_message'; } else { if ( !empty( $secondary_item_id ) ) { //nada } else { $text = sprintf( __( 'You have %d new birthday of %s', 'bbpress' ), (int) $total_items, $famoso_name ); } $filter = 'bp_activity_at_message_notification_message'; } } if ( 'string' === $format ) { //falta definir $famoso_link y mas $return = apply_filters( $filter, '<a href="' . esc_url( $famoso_link ) . '" title="birthday anounce">' . esc_html( $text ) . '</a>', (int) $total_items, $text, $famoso_link ); // $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link ); } } do_action( 'celbirthday_notifier_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
and then add notification this way:
function buddypress_celebrities_add_notification( $fecha_act, $famoso_name, $receiver_user_id) { if ( bp_is_active( 'notifications' ) ) { $fecha_act = date("Y-m-d"); $res_birth = $wpdb->get_results( "SELECT wp_best_favs.user_id, wp_postmeta.post_id FROM wp_best_favs LEFT JOIN wp_postmeta ON ( wp_postmeta.post_id = wp_best_favs.celeb_ID ) WHERE ( wp_postmeta.meta_key = 'fecha_na') AND (DAY( <code>wp_postmeta</code>.<code>meta_value</code> ) = DAY( '$fecha_act' )) AND (MONTH( <code>wp_postmeta</code>.<code>meta_value</code> ) = MONTH( '$fecha_act' ) ) ") ; $res_birth = array_filter($res_birth); $matriz = objectToArray($res_birth); //convertimos el array de objetos en array normal para manejarlo mas facil $current_time = bp_core_current_time(); if(count($matriz)==0) { // está vacío } else { global $wpdb; $bp = buddypress(); $subject = 'Celebrity birthday'; $message = '1 Say happy birthday to $famoso_name'; $content = '2 Say happy birthday to $famoso_name'; foreach ($matriz as $v1) { $famoso_id = $v1[post_id]; $famoso_name = get_the_title ($v1[post_id]); $receiver_user_id = $v1[user_id]; $args = array( 'user_id' => $receiver_user_id, 'item_id' => $famoso_id, 'secondary_item_id' => $famoso_id, 'component_name' => $bp->celbirthday_notifier->id, 'component_action' => 'new_birthday', 'date_notified' => $current_time, 'is_new' => 1, ); bp_notifications_add_notification( $args ); } } } } add_action( 'new_birthday', 'buddypress_celebrities_add_notification', 10, 1 );
so far this is what I am trying to do, hope you understand.
Thanks in advance.August 13, 2015 at 5:07 pm #243158In reply to: New User Notification Email to Admin
michaelpfaffParticipantI figured this out by cobbling together some code. Just copy this into a new .php file, upload to /plugins and activate. You’ll need to change ‘Referrer’ to whatever profile field you have instead.
<?php /* Plugin Name: Custom New User Email Description: Changes the copy in the email sent out to new users */ // Redefine user notification function if ( !function_exists('wp_new_user_notification') ) { function wp_new_user_notification( $user_id, $plaintext_pass = '' ) { $user = get_userdata( $user_id ); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); // find the profile field for referrer $field1 = xprofile_get_field_data( 'Referrer', $user_id ); $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n"; $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n\r\n"; $message .= sprintf(__('Referrer: %s'), $field1) . "\r\n"; @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); if ( empty($plaintext_pass) ) return; $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n"; $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; $message .= wp_login_url() . "\r\n"; wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message); } } ?>
August 13, 2015 at 4:03 pm #243155In reply to: Need urgent help with BP notifications
chicho1969ParticipantThanks for reply.
Yes I read those articles (…and much more), but still not understanding, Sorry about it, thus I am asking for help.
I don,t understand what do you mean with use a function name twice:
(// do_action( ‘setup_globals’ ); This is commented) ,is this a better way to do it?:
function sr_notifications_test_setup_globals () { global $bp, $current_blog; $bp->sr_notifications_test = new stdClass(); $bp->sr_notifications_test->id = 'sr_notifications_test'; $bp->sr_notifications_test->slug = 'sr_notifications_test'; $bp->sr_notifications_test->notification_callback = 'sr_format_notifications_test'; $bp->active_components[$bp->sr_notifications_test->id] = $bp->sr_notifications_test->id; do_action( 'sr_notifications_test_setup_globals ' ); } add_action( 'bp_notification_settings', 'sr_notifications_test_setup_globals ' );
Anyway, what I understood is that I have to write those 3 functions to make my custom notifications works:
1.- setup_globals
2.- format_notifications (called from set_up_globals, notification_callback)
If Iunderstood you´, the filter I have to use is bp_notifications_get_notifications_for_user
3.- _add_notificationis this the right way?
August 12, 2015 at 4:01 pm #243087In reply to: Need urgent help with BP notifications
chicho1969ParticipantOk, now I am trying this:
//function class function setup_globals( $args = array() ) { global $bp; $sr_notifications_test_slug = 'sr_notifications_test'; parent::setup_globals( array( 'id' => 'sr_notifications_test', 'slug' => $sr_notifications_test_slug, 'notification_callback' => array( $this, 'sr_format_notifications_test' ) ) ); /* Register this in the active components array */ $bp->active_components[$sr_notifications_test_slug] = 'sr_notifications_test'; // do_action( 'setup_globals' ); } //format notofication function sr_format_notifications_test( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { switch ( $action ) { case 'my_test': $link = get_permalink( $item_id ); $text = 'Test Notification'; $return = apply_filters( $filter, array( 'text' => $text, 'link' => $link ), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); break; } do_action( 'sr_format_notifications_test', $action, $item_id, $secondary_item_id, $total_items ); return $return; } //Notification added to DB: bp_notifications_add_notification( array( 'user_id' => $user_id, 'item_id' => $activity->id, 'secondary_item_id' => $activity->user_id, 'component_name' => buddypress()->activity->id, 'component_action' => 'my_test', 'date_notified' => bp_core_current_time(), 'is_new' => 1 ) ); print_r ($bp->active_components[$sr_notifications_test_slug]);
and this is the error I have: (still the same)
WordPress database error: [Table 'WP_db_funs.n' doesn't exist] SELECT * FROM n WHERE component_name IN ('activity') AND component_action IN ('my_test') AND is_new = 1 WordPress database error: [Incorrect table name ”] INSERT INTO (user_id,item_id,secondary_item_id,component_name,component_action,date_notified,is_new) VALUES (0,0,0,'activity','my_test','2015-08-12 15:57:21′,1)
Please if anybody Knows about this I will apreciate any help 🙁
Table ‘WP_db_funs.n’ doesn’t exist how come?? table n ??
August 11, 2015 at 9:36 pm #243060In reply to: [Resolved] Add Count Near Nav Menu
danbpParticipantI tested the snippet on Buddy theme, so i’m pretty sure you have a user menu. This menu is on WP’s Toolbar. You see it when you’re logged in.
To choose an item position, you have to do it differently, as explained here:
[Resolved] Position Notification Counter Bubble after Specific Navigation Tab ID
For more about menu handling and functions, see WP Codex, as this is not really related to BuddyPress. Now it’s your turn to work a little !
August 11, 2015 at 6:57 pm #243051In reply to: [Resolved] Add Count Near Nav Menu
gurselgunacarParticipant@danbp you are my hero. i tried to find this code for 2 weeks 🙂 you solved that. my theme doesnt contain user menu. So i need to add count of notification. Lastly how can we move this menu items left side of menu?
August 11, 2015 at 6:41 pm #243049In reply to: [Resolved] Add Count Near Nav Menu
danbpParticipantYes you can, but why would you do that as all those counters are already in the user menu (on top right, under Howdy) and on each profile ? Tsssss…., but you’re the boss ! 😉
To count friends use
friends_get_friend_count_for_user( bp_loggedin_user_id() );
To count messages usebp_get_total_unread_messages_count( bp_loggedin_user_id() )
Complete solutionfunction my_counter_nav_menu($menu) { $notif_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'notifications/'; $friends_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'friends/'; $msg_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'messages/'; if (!is_user_logged_in()) return $menu; else $notif = ' <li><a href=" ' .$notif_url. ' ">Notif ['. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .']</a></li> <li><a href=" ' .$friends_url. ' ">Friends ['. friends_get_friend_count_for_user( bp_loggedin_user_id() ) .']</a></li> <li><a href=" ' .$msg_url. ' ">Messages ['. bp_get_total_unread_messages_count( bp_loggedin_user_id() ) .']</a></li> '; $menu = $menu . $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_counter_nav_menu' );
Bu yardım olabilir ! 😉
August 11, 2015 at 5:51 pm #243047In reply to: [Resolved] Add Count Near Nav Menu
danbpParticipantAdd this to bp-custom.php and give a try ! Should show at the left of the logout button on Buddy theme nav bar
function my_nav_menu_notif_counter($menu) { $url = bp_core_get_user_domain(bp_loggedin_user_id()) .'notifications/'; // condition: user must be loggedin if (!is_user_logged_in()) return $menu; else $notif = '<li><a href=" ' .$url. ' ">Notif ['. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .']</a></li>'; $menu = $menu . $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter' );
August 3, 2015 at 6:26 pm #242729In reply to: Styling BuddyPress Login Widget
Jld142ParticipantThis is my current code:
<?php /* Link parent CSS file */ add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' ); function enqueue_parent_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' ); } /* Count number of user notifications */ function cg_current_user_notification_count() { $notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object'); $count = !empty($notifications) ? count($notifications) : 0; echo $count; } /* Remove register BuddyPress Widget creator */ function remove_bp_core_register_widgets() { remove_action(bp_core_register_widgets()); } add_action('init','remove_bp_core_register_widgets()'); function new_bp_core_register_widgets() { add_action('widgets_init', create_function('', 'return register_widget("new_BP_Core_Login_Widget");') ); } add_action( 'bp_register_widgets', 'bp_core_register_widgets' ); /* New BuddyPress Login Widget */ class new_BP_Core_Login_Widget extends WP_Widget { /** * Constructor method. */ public function __construct() { parent::__construct( false, _x( '(BuddyPress) Log In', 'Title of the login widget', 'buddypress' ), array( 'description' => __( 'Show a Log In form to logged-out visitors, and a Log Out link to those who are logged in.', 'buddypress' ), 'classname' => 'widget_bp_core_login_widget buddypress widget', ) ); } /** * Display the login widget. * * @see WP_Widget::widget() for description of parameters. * * @param array $args Widget arguments. * @param array $instance Widget settings, as saved by the user. */ public function widget( $args, $instance ) { $title = isset( $instance['title'] ) ? $instance['title'] : ''; /** * Filters the title of the Login widget. * * @since BuddyPress (1.9.0) * @since BuddyPress (2.3.0) Added 'instance' and 'id_base' to arguments passed to filter. * * @param string $title The widget title. * @param array $instance The settings for the particular instance of the widget. * @param string $id_base Root ID for all widgets of this type. */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); echo $args['before_widget']; echo $args['before_title'] . esc_html( $title ) . $args['after_title']; ?> <?php if ( is_user_logged_in() ) : ?> <?php /** * Fires before the display of widget content if logged in. * * @since BuddyPress (1.9.0) */ do_action( 'bp_before_login_widget_loggedin' ); ?> <div class="bp-login-widget-user-avatar"> <a href="<?php echo bp_loggedin_user_domain(); ?>"> <?php bp_loggedin_user_avatar( 'type=thumb&width=50&height=50' ); ?> </a> </div> <div class="bp-login-widget-user-links"> <div class="bp-login-widget-user-link"><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></div> <p>TEST</p> <div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( bp_get_requested_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div> </div> <?php /** * Fires after the display of widget content if logged in. * * @since BuddyPress (1.9.0) */ do_action( 'bp_after_login_widget_loggedin' ); ?> <?php else : ?> <?php /** * Fires before the display of widget content if logged out. * * @since BuddyPress (1.9.0) */ do_action( 'bp_before_login_widget_loggedout' ); ?> <form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> <label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label> <input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" /> <label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label> <input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" <?php bp_form_field_attributes( 'password' ) ?> /> <div class="forgetmenot"><label><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div> <input type="submit" name="wp-submit" id="bp-login-widget-submit" value="<?php esc_attr_e( 'Log In', 'buddypress' ); ?>" /> <?php if ( bp_get_signup_allowed() ) : ?> <span class="bp-login-widget-register-link"><?php printf( __( '<a href="%s" title="Register for a new account">Register</a>', 'buddypress' ), bp_get_signup_page() ); ?></span> <?php endif; ?> </form> <?php /** * Fires after the display of widget content if logged out. * * @since BuddyPress (1.9.0) */ do_action( 'bp_after_login_widget_loggedout' ); ?> <?php endif; echo $args['after_widget']; } /** * Update the login widget options. * * @param array $new_instance The new instance options. * @param array $old_instance The old instance options. * @return array $instance The parsed options to be saved. */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = isset( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : ''; return $instance; } /** * Output the login widget options form. * * @param $instance Settings for this widget. */ public function form( $instance = array() ) { $settings = wp_parse_args( $instance, array( 'title' => '', ) ); ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $settings['title'] ); ?>" /></label> </p> <?php } } ?>
I was trying to following the below guide to remove the function that initializes the login widget and then redirect it to my own new one:
http://venutip.com/content/right-way-override-theme-functions
Obviously hasn’t worked. Any ideas ?
July 20, 2015 at 8:12 pm #242052In reply to: Get Post ID from Notification
creativesinsideParticipantobject(BP_Notifications_Notification)#394 (8) { ["id"]=> string(3) "297" ["item_id"]=> string(3) "242" ["secondary_item_id"]=> string(1) "1" ["user_id"]=> string(1) "1" ["component_name"]=> string(8) "messages" ["component_action"]=> string(11) "new_message" ["date_notified"]=> string(19) "2015-07-20 20:11:46" ["is_new"]=> string(1) "0" }
The actual Post ID in question is 756.
-
AuthorSearch Results