Search Results for 'toolbar'
-
Search Results
-
Hi,
Is there a way to hide the rich text editor toolbar in a multi-line text area field based on the users role.
I don’t want to have to create separate fields for each user role.
Thank you
I need some custom notifications in my website. I have my code bellow, all work correctly, notification is added into database and displayed at the recipient, but without notification text
How i can fix this?
Thank youfunction custom_filter_notifications_get_registered_components( $component_names = array() ) { // Force $component_names to be an array if ( ! is_array( $component_names ) ) { $component_names = array(); } // Add 'custom' component to registered components array array_push( $component_names, 'custom' ); // Return component's with 'custom' appended return $component_names; } add_filter( 'bp_notifications_get_registered_components', 'custom_filter_notifications_get_registered_components' ); function custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { // New custom notifications if ( 'custom_action' === $action ) { $custom_title = "You have new notification"; $custom_link = "domain.com"; $custom_text = "You have new notification"; // WordPress Toolbar if ( 'string' === $format ) { $return = apply_filters( 'custom_filter', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link ); // Deprecated BuddyBar } else { $return = apply_filters( 'custom_filter', array( 'text' => $custom_text, 'link' => $custom_link ), $custom_link, (int) $total_items, $custom_text, $custom_title ); } return $return; } } add_filter( 'bp_notifications_get_notifications_for_user', 'custom_format_buddypress_notifications', 10, 5 ); function bp_custom_add_notification( $receiver_user_id, $initiator ) { //$post = get_post( $comment_object->comment_post_ID ); //$author_id = $post->post_author; bp_notifications_add_notification( array( 'user_id' => $receiver_user_id, 'item_id' => $initiator, 'secondary_item_id' => $initiator, 'component_name' => 'custom', 'component_action' => 'custom_action', 'date_notified' => bp_core_current_time(), 'is_new' => 1, ) ); } add_action( 'wp_insert_custom_notification', 'bp_custom_add_notification', 99, 2 );
Topic: New Topic Notification
Hi,
I have created a custom notification for my site when a post is published, the code used to do this is :-
// this is to add a fake component to BuddyPress. A registered component is needed to add notifications function custom_filter_notifications_get_registered_components( $component_names = array() ) { // Force $component_names to be an array if ( ! is_array( $component_names ) ) { $component_names = array(); } // Add 'custom' component to registered components array array_push( $component_names, 'publishpost' ); // Return component's with 'custom' appended return $component_names; } add_filter( 'bp_notifications_get_registered_components', 'custom_filter_notifications_get_registered_components' ); // this hooks to post creation and saves the post id function bp_custom_add_notification( $post_id, $post ) { $post = get_post( $post_id ); $author_id = $post->post_author; $blogusers = get_users( array( 'role' => 'staff' ) ); // Array of WP_User objects. foreach ( $blogusers as $user ) { bp_notifications_add_notification( array( 'user_id' => $user->id, 'item_id' => $post_id, 'component_name' => 'publishpost', 'component_action' => 'publishpost_action', 'date_notified' => bp_core_current_time(), 'is_new' => 1, ) ); } } add_action( 'publish_post', 'bp_custom_add_notification', 99, 2 ); /** * Format the BuddyBar/Toolbar notifications * * @since bbPress (r5155) * * @package bbPress * * @param string $action The kind of notification being rendered * @param int $item_id The primary item id * @param int $secondary_item_id The secondary item id * @param int $total_items The total number of messaging-related notifications waiting for the user * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar */ function custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { // New custom notifications if ( 'publishpost_action' === $action ) { $post = get_post( $item_id ); $author_name = get_the_author_meta('display_name', $post->post_author); $custom_title = bp_core_get_user_displayname( $post->post_author ) . ' published a new post "' . get_the_title( $item_id ) . '"'; $custom_link = get_permalink( $post ); $custom_text = bp_core_get_user_displayname( $post->post_author ) . ' published a new post "' . get_the_title( $item_id ) . '"'; // WordPress Toolbar if ( 'string' === $format ) { $return = apply_filters( 'publishpost_filter', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link ); // Deprecated BuddyBar } else { $return = apply_filters( 'publishpost_filter', array( 'text' => $custom_text, 'link' => $custom_link ), $custom_link, (int) $total_items, $custom_text, $custom_title ); } return $return; } if ( 'bbp_new_reply' === $action ) { $topic_id = bbp_get_reply_topic_id( $item_id ); $topic_title = bbp_get_topic_title( $topic_id ); $topic_link = wp_nonce_url( add_query_arg( array( 'action' => 'bbp_mark_read', 'topic_id' => $topic_id ), bbp_get_reply_url( $item_id ) ), 'bbp_mark_topic_' . $topic_id ); $title_attr = __( 'Topic Replies', 'bbpress' ); if ( (int) $total_items > 1 ) { $text = sprintf( __( 'You have %d new replies', 'bbpress' ), (int) $total_items ); $filter = 'bbp_multiple_new_subscription_notification'; } else { if ( !empty( $secondary_item_id ) ) { $text = sprintf( __( 'You have %d new reply to %2$s from %3$s', 'bbpress' ), (int) $total_items, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) ); } else { $text = sprintf( __( 'You have %d new reply to %s', 'bbpress' ), (int) $total_items, $topic_title ); } $filter = 'bbp_single_new_subscription_notification'; } // WordPress Toolbar if ( 'string' === $format ) { $return = apply_filters( $filter, '<a href="' . esc_url( $topic_link ) . '" title="' . esc_attr( $title_attr ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $text, $topic_link ); // Deprecated BuddyBar } else { $return = apply_filters( $filter, array( 'text' => $text, 'link' => $topic_link ), $topic_link, (int) $total_items, $text, $topic_title ); } do_action( 'bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items ); return $return; } } add_filter( 'bp_notifications_get_notifications_for_user', 'custom_format_buddypress_notifications', 1, 5 );
How can i create the same for a new bbpress topic? i’m thinking i need to change this code section but not sure how
// this hooks to post creation and saves the post id function bp_custom_add_notification( $post_id, $post ) { $post = get_post( $post_id ); $author_id = $post->post_author; $blogusers = get_users( array( 'role' => 'staff' ) ); // Array of WP_User objects. foreach ( $blogusers as $user ) { bp_notifications_add_notification( array( 'user_id' => $user->id, 'item_id' => $post_id, 'component_name' => 'publishpost', 'component_action' => 'publishpost_action', 'date_notified' => bp_core_current_time(), 'is_new' => 1, ) ); } } add_action( 'publish_post', 'bp_custom_add_notification', 99, 2 );
I am using woffice as the theme, bbpress version 2.5.14, buddypress version 4.1.0 and the latest version of wordpress
Thanks
Hi, I am a using a combination of WP Members and Buddypress.
I use Buddypress for the activity registration and the extended profile fields.As an admin I can see and edit the extended profile field of my members, but they do not have the toolbar. How can I add a ‘my profile page’ where they can see and edit their extended fields and activities?
They can now only see it when they click on their own picture at ‘who’s online’.Thanks for the help!
hey guys,
when the user have read/clicked on a notification then the notifitcation should automatically delete. i want to do that with a ajax call.so my idea is to add a filter on the function bp_notifications_get_notifications_for_user() to manipulate the output.
but i need for the ajax call a notification_id. so that he knows which notofiation he has to delete.add_filter( 'bp_notifications_get_notifications_for_user', 'bp_follow_notify_format_notifications', 9, 5 ); function bp_follow_notify_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { if ( 'follow_new_post' === $action ) { if ( (int) $total_items > 1 ) { $title = sprintf( __( '%d new posts have been published', 'bp-follow-notify' ), (int) $total_items ); $link = bp_get_notifications_permalink(); } else { $title = sprintf( __( '%s is kiteboarding.', 'bp-follow-notify' ), bp_core_get_user_displayname( $secondary_item_id ) ); $link = get_permalink( $item_id ); } // WordPress Toolbar if ( 'string' === $format ) { $return = apply_filters('bp_follow_notify_notification', '<div onClick="clickedOnNotification('.$notificationID.')" title="' . esc_attr( $title ) . '">' . esc_html( $title ) . '"</div>', $title, site_url().$link ); // Deprecated BuddyBar } else { $return = apply_filters( 'bp_follow_notify_notification', array( 'text' => $title, 'link' => $link ), $link, (int) $total_items, $title, $title ); } return $return; } return $action; }
here is the important line.
$return = apply_filters('bp_follow_notify_notification', '<div
onClick=”clickedOnNotification(‘.$notificationID.’)”title="' . esc_attr( $title ) . '">' . esc_html( $title ) . '"</div>', $title, site_url().$link );
cheers Pau
Hi,
i enabled the option that show the toolbar to the visitor of my website but it does not work. How i can resolve this problem?
BuddyPress Plugin Version: 3.1.0
WordPress Version 4.9.6-it_IT