BuddyDev

Search

BP Live Notification – change notification href / add tag in content

  • Participant
    Level: Initiated
    Posts: 1
    Andrew on #26662

    Hello!
    First of all, I would like to thank you for all your plugins and all your work!!! I found so many useful information on your site! Especially I really appreciate your support; you are always here to help your customers! To be honest, when I install some new plugin, every time I prefer to pick a plugin made by your team, because I know that there are always be a great support!
    So, I have a just little question about your plugin BP Live Notification.
    If I understand well, to create the content of notification you use same block as core BP files.
    In your code (bp-live-notification/bp-live-notification.php: line 123):
    $description = call_user_func( $bp->{$notification->component_name}->notification_callback, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 );

    So, for friends accepted request notification we get message like this:
    <a href=“my_site_url/user_nicename/friends_slug/my-friends/“>some_user accepted your friendship request</a>

    I would like to know:

    1. Is it possible to change href of a tag where the content of notification is put? In my case I would like to remove a part of href ‘/my-friends’ (buddypress/bp-friends/bp-friends-notifications.php: line 34):
    $link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends' );

    I would like it to be:
    $link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() );

    And (buddypress/bp-friends/bp-friends-notifications.php: line 51)

    Remove “?new” from this:
    $link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';

    2. Do you think it’s possible to change somehow content itself of notifications? I mean, I can change, of course, this text in the .po files, but maybe it is better to change it through php hook? For example, I would like to put a username in span tag (to be able to use some custom css).
    Something like this:
    <a href=“my_site_url/user_nicename/friends_slug/my-friends/“><span class=“my-class-username”>some_user</span> accepted your friendship request</a>

    Thank you again for all of your work!!!
    Andrew.

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #26665

    Hi Andrew,
    Welcome to BuddyDev forums.

    Thank you for the kind words. I am glad that you like our work.

    I checked the plugin and as you already found, the link and text are generated by BuddyPress and not us.

    We have a filter ‘bp_get_the_notification_description’ that gets complete html link for each notification. It may be used to filter. If you want, I can pass the notification object with it.

    The correct way to do it will be to filter it for specific component( eg. friends and the generated output from their notification call back).

    For friends, you may want to look at “friends_format_notifications” in buddypress/buddypress-friends/bp-friends-notifications.php

    They have filters for it.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 1
    Andrew on #26667

    Hi Brajesh,
    Thank you for your prompt response!
    If you can give me an example of the code to how change this link, I would really appreciate it.
    Thank you in advance.

You must be logged in to reply to this topic.

This topic is: not resolved