Custom notification text don’t show on front page
-
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 );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.