This topic has 4 replies, 2 voices, and was last updated 8 years by sharmstr.

  • Author
  • #99058
     kent
    Participant

    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

    #99062
     sharmstr
    Moderator

    Visit 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 solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #99087
     kent
    Participant

    It’s not working on any theme. It seems function problem.

    #99108
     sharmstr
    Moderator

    That’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 solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #99109
     sharmstr
    Moderator

    moving 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 solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘Plugins questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?