Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to send a notification with email.


  • tim.samuelsson
    Participant

    @timsamuelsson

    Hi,

    I have manage to do the following:
    1. Create an activity
    2. Create a notification for that activity

    I have used the following code as proof of concept:

    add_action('bp_ready', function() {
        //1. Add an action
        $activity_id = bp_activity_add([
            'action' => '<b>HEJHEJHEJ</b>',
            'content' => '<b>my content my content my content my content my content my content</b>',
            'component' => 'groups',
            'type' => 'activity_update',
            'user_id' => get_current_user_id(),
        ]);
    
        //2. Send the notification
        if (bp_is_active('notifications')) {
            $activity = new BP_Activity_Activity($activity_id);
            $notification = bp_notifications_add_notification(array(
                'item_id' => $activity->id,
                'secondary_item_id' => $activity->user_id,
                'user_id' => $activity->user_id,
                'component_name' => buddypress()->activity->id,
                'component_action' => 'new_at_mention',
                'date_notified' => bp_core_current_time(),
                'is_new' => 1,
            ));
        }
    });

    So how do i make Buddypress to send an email to the user about that notification? Is there any tutorial that describes the process?

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

  • shanebp
    Moderator

    @shanebp

    Try adding a call to wp_mail.
    There are several examples of that in codebase.
    For example, see function bp_activity_at_message_notification
    in buddypress\bp-activity\bp-activity-notifications.php


    tim.samuelsson
    Participant

    @timsamuelsson

    Thanks!

    I have som other questions about adding activities and notifications.

    ———————-

    How is these params used by the bp_activity_add function? What are they used for?

    ‘item_id’
    ‘secondary_item_id’

    ——

    About bp_notifications_add_notification params.

    How is the item_id used?
    How is the secondary_item_id used?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to send a notification with email.’ is closed to new replies.
Skip to toolbar