-
Author
-
January 18, 2016 at 10:20 #99058kentParticipant
Hey,
I was trying to make an custom notifications for buddypress and the notifications are saving, but when we visit the user notifications page or live notification box on top, it does not show the “text” of notification. I was wondering if the theme “KLEO” supports custom notifications if yes then which format it does support, an little help would be great to achieve this.
Below codes are using for saving the 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, ‘collection’ );// 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’ ) {
global $wpdb;
// New custom notifications
if ( ‘collection_action’ === $action ) {
$collection = $wpdb->get_results(“SELECT * FROM wprg_yith_wcwl_lists WHERE ID = $item_id”);
$user_info = get_userdata(get_current_user_id());
$custom_title = $user_info->display_name . ‘ added product in ‘ . $collection[0]->wishlist_name;
$custom_link = site_url().’collections/view/’.$collection[0]->wishlist_token;
$custom_text = $user_info->display_name . ‘ added product in ‘ . $collection[0]->wishlist_name;
$filter = ‘collection_multiple_new_product_notification’;
if ( ‘string’ === $format ) {
$return = apply_filters( $filter, ‘<a href=”‘ . esc_url( $custom_link ) . ‘” title=”‘ . esc_attr( $custom_title ) . ‘”>’ . esc_html( $custom_text ) . ‘</a>’, $custom_text, $custom_link );} else {
$return = apply_filters( $filter, array(
‘text’ => $custom_text,
‘link’ => $custom_link
), $custom_link, (int) $total_items, $custom_text, $custom_title );
}
do_action(‘custom_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’, 8, 5 );Thanks
January 18, 2016 at 12:01 #99062sharmstrModeratorVisit the user notification page with the WP 2015 Theme enabled. Does your notification show up?
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
January 18, 2016 at 15:40 #99087kentParticipantIt’s not working on any theme. It seems function problem.
January 18, 2016 at 17:06 #99108sharmstrModeratorThat’s what I figured since Kleo doesnt override the buddypress notification code.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
January 18, 2016 at 17:06 #99109sharmstrModeratormoving this topic since its not a bug.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘Plugins questions’ is closed to new topics and replies.