Search Results for 'notification user id'
-
AuthorSearch Results
-
September 9, 2015 at 11:30 pm #244204
In reply to: Logged in home page
danbp
ParticipantTo 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)?
danbp
Participanthi 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)?
AilyRoot
ParticipantHi 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
tr1stessa
ParticipantHello 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 #243760ctuxboy
ParticipantHello,
– 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
chicho1969
Participantokay, 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
chicho1969
ParticipantThanks @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
michaelpfaff
ParticipantI 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
chicho1969
ParticipantThanks 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
chicho1969
ParticipantOk, 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
danbp
ParticipantI 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
gurselgunacar
Participant@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
danbp
ParticipantYes 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
danbp
ParticipantAdd 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
Jld142
ParticipantThis 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
creativesinside
Participantobject(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.
July 20, 2015 at 7:11 pm #242048In reply to: Get Post ID from Notification
creativesinside
ParticipantIs 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
creativesinside
ParticipantAck 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
creativesinside
ParticipantThis 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
creativesinside
ParticipantIs 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
creativesinside
ParticipantCan 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
milenushka
ParticipantHi @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?
djsteveb
Participant@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
Osisis
ParticipantNot 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@mcuk
ParticipantThese 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' ); -
AuthorSearch Results
