Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to create custom notifications

  • Hi,
    I want to create custom notifications depends upon various activities of user on my site. What function/code do i have to use which triggers when user perform certain action on my site..

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,
    Is there anyone who have done this before? Or should i assume that this is something not possible?
    Thanks

    Avatar of Riente
    Riente
    Participant

    @riente

    Hello, if you’re still interested I had the same problem and found a solution I described in my blog here

    Glad if I could help :)

    Avatar of oriadam
    oriadam
    Participant

    @oriadam

    Hi @riente,
    I read your blog post twice but couldn’t get it…
    Did you edit the original BP code?
    Perhaps latest BP update changed the location of the function you edited.

    My code looks something like that:

    <?php
    require('wp-load.php');
    require_once('wp-includes/user.php');
    require_once('wp-includes/pluggable.php');
    require_once('wp-content/plugins/buddypress/bp-core/bp-core-loader.php');
    
    $from_id=get_current_user_id();
    if (empty($from_id)) exit; // do nothing if there's no current user
    ///////// ...some boring code here... ////////
    $sum=10; // for example
    $to_user_link = bp_core_get_userlink($to_id);
    $from_user_link = bp_core_get_userlink($from_id);
    
    $note_to="You got $sum points from $from_user_link"; // <--- notification to be sent to payee
    $note_from="You sent $sum points to $to_user_link";  // <--- notification to be sent to payer
    
    /********** Now how do I send the above notifications to the relevant users $from_id and $to_id? ********/
    bp_core_add_notification( $item_id, $to, $component_name, $component_action, $secondary_item_id);
    

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.