当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_notifications_add_notification函数代码示例

本文整理汇总了PHP中bp_notifications_add_notification函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_notifications_add_notification函数的具体用法?PHP bp_notifications_add_notification怎么用?PHP bp_notifications_add_notification使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_notifications_add_notification函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_notification

 /**
  *
  * @param int $post_id
  * @param int $post_author_id
  * @param int $user_id
  *
  * @return int|bool  notification id on success or false
  */
 function add_notification($post_id, $post_author_id, $user_id)
 {
     global $rtmedia;
     $args_add_noification = array('item_id' => $post_id, 'user_id' => $post_author_id, 'component_name' => $this->component_id, 'component_action' => $this->component_action . $post_id, 'secondary_item_id' => $user_id, 'date_notified' => bp_core_current_time());
     if (isset($rtmedia->options['buddypress_enableNotification']) && 0 !== intval($rtmedia->options['buddypress_enableNotification'])) {
         return bp_notifications_add_notification($args_add_noification);
     }
     return false;
 }
开发者ID:rtCamp,项目名称:rtMedia,代码行数:17,代码来源:RTMediaNotification.php

示例2: bp_course_add_notification

function bp_course_add_notification($args = '')
{
    global $bp;
    if (!bp_is_active('notifications') || !function_exists('bp_notifications_add_notification')) {
        return;
    }
    $defaults = array('user_id' => $bp->loggedin_user->id, 'item_id' => false, 'secondary_item_id' => false, 'component_name' => 'course', 'component_action' => '', 'date_notified' => bp_core_current_time(), 'is_new' => 1);
    $r = wp_parse_args($args, $defaults);
    extract($r);
    return bp_notifications_add_notification(array('user_id' => $user_id, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'component_name' => $component_name, 'component_action' => $component_action, 'date_notified' => $date_notified, 'is_new' => $is_new));
}
开发者ID:Nguyenkain,项目名称:Elearning,代码行数:11,代码来源:bp-course-activity.php

示例3: bp_em_add_booking_notification

/**
 * Catch booking saves and add a BP notification.
 * @param boolean $result
 * @param EM_Booking $EM_Booking
 * @return boolean
 */
function bp_em_add_booking_notification($result, $EM_Booking)
{
    global $bp;
    if (get_option('dbem_bookings_approval') && $EM_Booking->get_status() == 0) {
        $action = 'pending_booking';
    } elseif ($EM_Booking->get_status() == 1 || get_option('dbem_bookings_approval') && $EM_Booking->get_status() == 0) {
        $action = 'confirmed_booking';
    } elseif ($EM_Booking->get_status() == 3) {
        $action = 'cancelled_booking';
    }
    if (!empty($action) && !(get_option('dbem_bookings_registration_disable') && get_option('dbem_bookings_registration_user') == $EM_Booking->get_event()->get_contact()->ID)) {
        bp_notifications_add_notification(array('item_id' => $EM_Booking->booking_id, 'secondary_item_id' => $EM_Booking->event_id, 'user_id' => $EM_Booking->get_event()->get_contact()->ID, 'component_name' => 'events', 'component_action' => $action));
    }
    return $result;
}
开发者ID:sajjadalisiddiqui,项目名称:cms,代码行数:21,代码来源:bp-em-notifications.php

示例4: bp_follow_notifications_add_on_follow

/**
 * Adds notification when a user follows another user.
 *
 * @since 1.2.1
 *
 * @param object $follow The BP_Follow object.
 */
function bp_follow_notifications_add_on_follow(BP_Follow $follow)
{
    // Add a screen notification
    //
    // BP 1.9+
    if (bp_is_active('notifications')) {
        bp_notifications_add_notification(array('item_id' => $follow->follower_id, 'user_id' => $follow->leader_id, 'component_name' => buddypress()->follow->id, 'component_action' => 'new_follow'));
        // BP < 1.9 - add notifications the old way
    } elseif (!class_exists('BP_Core_Login_Widget')) {
        global $bp;
        bp_core_add_notification($follow->follower_id, $follow->leader_id, $bp->follow->id, 'new_follow');
    }
    // Add an email notification
    bp_follow_new_follow_email_notification(array('leader_id' => $follow->leader_id, 'follower_id' => $follow->follower_id));
}
开发者ID:vilmark,项目名称:vilmark_main,代码行数:22,代码来源:bp-follow-notifications.php

示例5: bp_core_add_notification

/**
 * Add a notification for a specific user, from a specific component
 *
 * @deprecated Deprecated since BuddyPress 1.9.0. Use
 *  bp_notifications_add_notification() instead.
 *
 * @since BuddyPress (1.0)
 * @param string $item_id
 * @param int $user_id
 * @param string $component_name
 * @param string $component_action
 * @param string $secondary_item_id
 * @param string $date_notified
 * @param int $is_new
 * @return boolean True on success, false on fail
 */
function bp_core_add_notification($item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false, $is_new = 1)
{
    // Bail if notifications is not active
    if (!bp_is_active('notifications')) {
        return false;
    }
    // Trigger the deprecated function notice
    _deprecated_function(__FUNCTION__, '1.9', 'bp_notifications_add_notification()');
    // Notifications must always have a time
    if (false === $date_notified) {
        $date_notified = bp_core_current_time();
    }
    // Add the notification
    return bp_notifications_add_notification(array('item_id' => $item_id, 'user_id' => $user_id, 'component_name' => $component_name, 'component_action' => $component_action, 'secondary_item_id' => $secondary_item_id, 'date_notified' => $date_notified, 'is_new' => $is_new));
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:31,代码来源:bp-members-notifications.php

示例6: _likebtn_bp_notifications_add_notification

function _likebtn_bp_notifications_add_notification($entity_name, $entity_id, $voter_id, $action)
{
    if (!in_array($action, array('like', 'dislike'))) {
        $action = 'like';
    }
    // No notifications from Anonymous
    if (!$voter_id) {
        return false;
    }
    $author_id = _likebtn_get_author_id($entity_name, $entity_id);
    if (!$author_id || $author_id == $voter_id) {
        return false;
    }
    bp_notifications_add_notification(array('user_id' => $author_id, 'item_id' => $entity_id, 'secondary_item_id' => $voter_id, 'component_name' => LIKEBTN_BP_COMPONENT_NAME, 'component_action' => 'likebtn_' . $entity_name . '_' . $action, 'date_notified' => bp_core_current_time(), 'is_new' => 1));
    // bp_notifications_add_meta($notification_id, 'entity_name', $entity_name, true)
}
开发者ID:pslorus,项目名称:WebsiteTinTuc,代码行数:16,代码来源:buddypress.php

示例7: add_new_comment_notification

 public function add_new_comment_notification($comment)
 {
     $comment = (object) $comment;
     if (bp_is_active('notifications')) {
         global $bp;
         $post = get_post($comment->comment_post_ID);
         if ($post->post_type == 'answer') {
             $participants = ap_get_parti(false, false, $comment->comment_post_ID);
         }
         if ($post->post_type == 'question') {
             $participants = ap_get_parti($comment->comment_post_ID);
         }
         $notification_args = array('item_id' => $comment->comment_ID, 'secondary_item_id' => $comment->user_id, 'component_name' => $bp->ap_notifier->id, 'component_action' => 'new_comment_' . $post->ID, 'date_notified' => bp_core_current_time(), 'is_new' => 1);
         if (!empty($participants) && is_array($participants)) {
             foreach ($participants as $p) {
                 if ($p->apmeta_userid != $comment->user_id) {
                     $notification_args['user_id'] = $p->apmeta_userid;
                     bp_notifications_add_notification($notification_args);
                 }
             }
         }
     }
 }
开发者ID:deepakd92,项目名称:anspress,代码行数:23,代码来源:bp.php

示例8: create_discussion_child

function create_discussion_child()
{
    $kt = $_POST['kt'];
    $user_receiver = $_POST["user_receiver"];
    $noidung = $_POST["cdcontent"];
    $tieude = $_POST["cdtitle"];
    $courseid = $_POST["cdcourseid"];
    $listauthor = wp_get_current_user();
    $author = $listauthor->display_name;
    $mail_author = $listauthor->user_mail;
    $parent_comment = $_POST["parent_comment"];
    $student_id_array = lay_danh_sach_hoc_vien_khoa_hoc($courseid);
    $data = array('comment_post_ID' => $courseid, 'comment_author' => $author, 'comment_content' => $noidung, 'user_id' => get_current_user_id(), 'comment_author_mail' => $mail_author, 'comment_parent' => $parent_comment);
    $getid = wp_insert_comment($data);
    update_comment_meta($getid, 'review_title', $tieude);
    update_comment_meta($getid, 'title_discussion', $tieude);
    //    Lấy id củ của bảng messages và cộng thêm 1 để tạo thành Thread_id
    global $wpdb;
    $old_id = 0;
    $old_id_message = $wpdb->get_results('SELECT id FROM itclass_songle_bp_messages_messages ORDER BY id DESC LIMIT 1 ');
    foreach ($old_id_message as $item) {
        $old_id = $item->id + 1;
    }
    //    Thêm dữ liệu vào bảng messages
    $user = get_userdata(get_current_user_id());
    //$user->user_nicename
    $time_messages = current_time('mysql');
    $messsage_title = $user->user_nicename . ' đã bình luận tại khóa học <a href=\\"' . get_permalink($courseid) . '\\"><b>' . get_the_title($courseid) . '</b></a>';
    $wpdb->get_results('INSERT INTO itclass_songle_bp_messages_messages (thread_id,sender_id,subject,message,date_sent) VALUES ("' . $old_id . '","' . get_current_user_id() . '","' . $messsage_title . '","' . $noidung . '","' . $time_messages . '")');
    if (!empty($student_id_array)) {
        foreach ($student_id_array as $student_id) {
            if ($student_id != get_current_user_id()) {
                //    Thêm hành động bình luận
                $datacomment = array('action' => 'Học viên đã bình luận tại khóa học ' . get_the_title($courseid), 'user_id' => get_current_user_id(), 'component' => 'comments_unit', 'type' => 'activity_update', 'content' => $noidung, 'primary_link' => get_permalink($courseid), 'item_id' => $courseid, 'secondary_item_id' => $student_id);
                $activity_id = bp_activity_add($datacomment);
                //    Thêm thông báo
                $datanotify = array('user_id' => $student_id, 'item_id' => $getid, 'secondary_item_id' => get_current_user_id(), 'component' => 'comments', 'component_name' => 'messages', 'is_new' => 1, 'component_action' => 'new_message');
                bp_notifications_add_notification($datanotify);
                $wpdb->get_results('INSERT INTO itclass_songle_bp_messages_recipients (user_id,thread_id,unread_count,sender_only,is_deleted) VALUES ("' . $student_id . '","' . $old_id . '",1,0,0)');
            }
        }
    }
    //    echo "<div class='result'>";
    $noidungsau = get_comment_text($getid);
    echo '<div class="result">';
    echo '<li>';
    echo '<div class="item-discustion child">';
    echo '<div class="cmtauthor child row">';
    echo '<div class="HieuChinh-ds child">';
    echo '<div class="Xoads"><i class="icon-x"></i> </div>';
    echo '<div class="Suads"><i class="icon-edit-pen-1"></i> </div>';
    echo '<input class="id-comment-ds" type="hidden" value="' . $getid . '">';
    echo '</div>';
    echo '<div class="col-md-1">';
    echo get_avatar(get_current_user_id(), 32);
    echo '</div>';
    echo '<div class="col-md-10">';
    echo '<span class="authorname">' . $author . '</span>' . '<span style="font-style:italic"> vừa xong </span>';
    echo '</div></div><br> ';
    echo '<div data-id="' . $getid . '" data-course-id="' . $courseid . '" class="NoiDungCMTUser row">';
    echo '<div class="col-md-1"></div>';
    echo '<div class="col-md-10">';
    echo '<div class="comment-title-user">' . get_comment_meta($getid, 'title_discussion', true) . ' </div>';
    echo '<div class="comment-content-user">' . $noidungsau . '</div>';
    echo '</div></div>';
    echo '<div class="edit_content_editor_child"></div>';
    echo '</div>';
    echo '</li>';
    die;
}
开发者ID:songlequang,项目名称:myclass,代码行数:70,代码来源:functions.php

示例9: notify

 public function notify($user_id, $comment)
 {
     $comment_id = $comment->comment_ID;
     bp_notifications_add_notification(array('item_id' => $comment_id, 'user_id' => $user_id, 'component_name' => $this->id, 'component_action' => 'new_blog_comment_' . $comment_id));
     $this->mark_notified($comment_id);
 }
开发者ID:bazalt,项目名称:bp-notify-post-author-on-blog-comment,代码行数:6,代码来源:bp-blog-comment-notifier.php

示例10: bp_activity_at_mention_add_notification

/**
 * Notify a member when their nicename is mentioned in an activity stream item.
 *
 * Hooked to the 'bp_activity_sent_mention_email' action, we piggy back off the
 * existing email code for now, since it does the heavy lifting for us. In the
 * future when we separate emails from Notifications, this will need its own
 * 'bp_activity_at_name_send_emails' equivalent helper function.
 *
 * @since 1.9.0
 *
 * @param object $activity           Activity object.
 * @param string $subject (not used) Notification subject.
 * @param string $message (not used) Notification message.
 * @param string $content (not used) Notification content.
 * @param int    $receiver_user_id   ID of user receiving notification.
 */
function bp_activity_at_mention_add_notification($activity, $subject, $message, $content, $receiver_user_id)
{
    if (bp_is_active('notifications')) {
        bp_notifications_add_notification(array('user_id' => $receiver_user_id, 'item_id' => $activity->id, 'secondary_item_id' => $activity->user_id, 'component_name' => buddypress()->activity->id, 'component_action' => 'new_at_mention', 'date_notified' => bp_core_current_time(), 'is_new' => 1));
    }
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:22,代码来源:bp-activity-notifications.php

示例11: groups_notification_group_invites

/**
 * Notify a member they have been invited to a group.
 *
 * @since 1.0.0
 *
 * @param BP_Groups_Group  $group           Group object.
 * @param BP_Groups_Member $member          Member object.
 * @param int              $inviter_user_id ID of the user who sent the invite.
 */
function groups_notification_group_invites(&$group, &$member, $inviter_user_id)
{
    // Bail if member has already been invited.
    if (!empty($member->invite_sent)) {
        return;
    }
    // @todo $inviter_ud may be used for caching, test without it
    $inviter_ud = bp_core_get_core_userdata($inviter_user_id);
    $invited_user_id = $member->user_id;
    // Trigger a BuddyPress Notification.
    if (bp_is_active('notifications')) {
        bp_notifications_add_notification(array('user_id' => $invited_user_id, 'item_id' => $group->id, 'component_name' => buddypress()->groups->id, 'component_action' => 'group_invite'));
    }
    // Bail if member opted out of receiving this email.
    if ('no' === bp_get_user_meta($invited_user_id, 'notification_groups_invite', true)) {
        return;
    }
    $invited_link = bp_core_get_user_domain($invited_user_id) . bp_get_groups_slug();
    $unsubscribe_args = array('user_id' => $invited_user_id, 'notification_type' => 'groups-invitation');
    $args = array('tokens' => array('group' => $group, 'group.url' => bp_get_group_permalink($group), 'group.name' => $group->name, 'inviter.name' => bp_core_get_userlink($inviter_user_id, true, false, true), 'inviter.url' => bp_core_get_user_domain($inviter_user_id), 'inviter.id' => $inviter_user_id, 'invites.url' => esc_url($invited_link . '/invites/'), 'unsubscribe' => esc_url(bp_email_get_unsubscribe_link($unsubscribe_args))));
    bp_send_email('groups-invitation', (int) $invited_user_id, $args);
}
开发者ID:buddypress,项目名称:BuddyPress-build,代码行数:31,代码来源:bp-groups-notifications.php

示例12: bbp_buddypress_add_notification

/**
 * Hooked into the new reply function, this notification action is responsible
 * for notifying topic and hierarchical reply authors of topic replies.
 *
 * @since 2.5.0 bbPress (r5156)
 *
 * @param int $reply_id
 * @param int $topic_id
 * @param int $forum_id (not used)
 * @param array $anonymous_data (not used)
 * @param int $author_id
 * @param bool $is_edit Used to bail if this gets hooked to an edit action
 * @param int $reply_to
 */
function bbp_buddypress_add_notification($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false, $reply_to = 0)
{
    // Bail if somehow this is hooked to an edit action
    if (!empty($is_edit)) {
        return;
    }
    // Get autohr information
    $topic_author_id = bbp_get_topic_author_id($topic_id);
    $secondary_item_id = $author_id;
    // Hierarchical replies
    if (!empty($reply_to)) {
        $reply_to_item_id = bbp_get_topic_author_id($reply_to);
    }
    // Get some reply information
    $args = array('user_id' => $topic_author_id, 'item_id' => $topic_id, 'component_name' => bbp_get_component_name(), 'component_action' => 'bbp_new_reply', 'date_notified' => get_post($reply_id)->post_date);
    // Notify the topic author if not the current reply author
    if ($author_id !== $topic_author_id) {
        $args['secondary_item_id'] = $secondary_item_id;
        bp_notifications_add_notification($args);
    }
    // Notify the immediate reply author if not the current reply author
    if (!empty($reply_to) && $author_id !== $reply_to_item_id) {
        $args['secondary_item_id'] = $reply_to_item_id;
        bp_notifications_add_notification($args);
    }
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:40,代码来源:notifications.php

示例13: save_event

 /**
  * Save or update a new event
  * @version 2.0
  */
 function save_event($post_id, $post = '')
 {
     // Don't do anything if it's not an event
     if ('event' != $post->post_type) {
         return;
     }
     // Verify the nonce before proceeding.
     if (!isset($_POST['event-details-box']) || !wp_verify_nonce($_POST['event-details-box'], basename(__FILE__))) {
         return $post_id;
     }
     /* -----------------------------------
     			SAVE EVENT TIME 
     		------------------------------------*/
     // Retrieve the event time
     $event_time = date('Y-m-d H:i:s', strtotime($_POST['event-time']));
     $prior_time = $post->post_date;
     // Update the post object
     $post->post_date = $event_time;
     remove_action('save_post', array($this, 'save_event'));
     wp_update_post($post);
     add_action('save_post', array($this, 'save_event'), 10, 2);
     /* -----------------------------------
     			SAVE META INFORMATION 
     		------------------------------------ */
     // Define the meta to look for
     $meta = array('event_duration' => $_POST['event-duration'], 'event_capacity' => $_POST['event-capacity'], 'event_rsvp' => $_POST['event-rsvp'], 'event_role' => $_POST['event-role']);
     // Loop through each meta, saving it to the database
     foreach ($meta as $meta_key => $new_meta_value) {
         // Get the meta value of the custom field key.
         $meta_value = get_post_meta($post_id, $meta_key, true);
         // If there is no new meta value but an old value exists, delete it.
         if (current_user_can('delete_post_meta', $post_id, $meta_key) && '' == $new_meta_value && $meta_value) {
             delete_post_meta($post_id, $meta_key, $meta_value);
         } elseif (current_user_can('add_post_meta', $post_id, $meta_key) && $new_meta_value && '' == $meta_value) {
             add_post_meta($post_id, $meta_key, $new_meta_value, true);
         } elseif (current_user_can('edit_post_meta', $post_id, $meta_key) && $new_meta_value && $new_meta_value != $meta_value) {
             update_post_meta($post_id, $meta_key, $new_meta_value);
         }
     }
     // Delete the RSVP meta if the date has changed
     if ($event_time != $prior_time) {
         delete_post_meta($post_id, 'event_rsvps');
     }
     /* -----------------------------------
     			BUDDYPRESS NOTIFICATION
     		------------------------------------ */
     // Get event data
     global $bp, $wpdb;
     if (!$user_id) {
         $user_id = $post->post_author;
     }
     // Figure out which calendars this event belongs to
     $calendars = wp_get_post_terms($post_id, 'calendar');
     $group_slugs = array();
     // For each calendar, check if it's a group calendar
     foreach ($calendars as $calendar) {
         if (is_group_calendar($calendar->term_id)) {
             $groups[] = $calendar;
         }
     }
     // If this event does not belong to a group, we can stop here
     if (empty($groups)) {
         return $post_id;
     }
     // Only register notifications for future or published events
     if (!in_array($post->post_status, array('publish', 'future'))) {
         return $post_id;
     }
     // Loop through each group, adding an activity entry for each one
     foreach ($groups as $group) {
         // Get the group data
         $group_id = groups_get_id($group->slug);
         $group_name = $group->name;
         // Configure the activity entry
         $post_permalink = get_permalink($post_id);
         $activity_action = sprintf('%1$s added the event %2$s to the %3$s.', bp_core_get_userlink($post->post_author), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', $group_name . ' <a href="' . SITEURL . '/calendar/' . $group->slug . '">group calendar</a>');
         $activity_content = $post->post_content;
         // Check for existing entry
         $activity_id = bp_activity_get_activity_id(array('user_id' => $user_id, 'component' => $bp->groups->id, 'type' => 'new_calendar_event', 'item_id' => $group_id, 'secondary_item_id' => $post_id));
         // Record the entry
         groups_record_activity(array('id' => $activity_id, 'user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $post_permalink, 'type' => 'new_calendar_event', 'item_id' => $group_id, 'secondary_item_id' => $post_id));
         // Update the group's last activity meta
         groups_update_groupmeta($group_id, 'last_activity', bp_core_current_time());
         // Maybe notify every group member
         if ($_POST['event-rsvp']) {
             if (bp_group_has_members($args = array('group_id' => $group_id, 'exclude_admins_mods' => false, 'per_page' => 99999))) {
                 while (bp_members()) {
                     bp_the_member();
                     // Remove any existing notifications ( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false )
                     bp_notifications_delete_notifications_by_item_id(bp_get_group_member_id(), $group_id, $bp->groups->id, 'new_calendar_event', $post_id);
                     // Send a notification ( itemid , groupid , component, action , secondary )
                     bp_notifications_add_notification(array('user_id' => bp_get_group_member_id(), 'item_id' => $group_id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_calendar_event'));
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:tamriel-foundry,项目名称:apoc2,代码行数:101,代码来源:events.php

示例14: notifyAllUsers

 public static function notifyAllUsers()
 {
     global $wpdb;
     if (!empty($_GET['nonce']) and wp_verify_nonce($_GET['nonce'], CMA_BaseController::ADMIN_BP_NOTIFY)) {
         $usersIds = $wpdb->get_col("SELECT ID FROM {$wpdb->users}");
         if (!empty($_GET['post_id']) and $thread = CMA_Thread::getInstance($_GET['post_id'])) {
             $notification = array('item_id' => $thread->getId(), 'secondary_item_id' => 0, 'component_name' => 'cma_notifier', 'component_action' => self::ACTION_NOTIFICATION_THREAD, 'date_notified' => bp_core_current_time(), 'is_new' => 1, 'allow_duplicate' => true);
             foreach ($usersIds as $userId) {
                 if ($thread->isVisible($userId)) {
                     $notification['user_id'] = $userId;
                     bp_notifications_add_notification($notification);
                 }
             }
         }
         if (!empty($_GET['comment_id']) and $answer = CMA_Answer::getById($_GET['comment_id'])) {
             $notification = array('item_id' => $answer->getId(), 'secondary_item_id' => 0, 'component_name' => 'cma_notifier', 'component_action' => self::ACTION_NOTIFICATION_ANSWER, 'date_notified' => bp_core_current_time(), 'is_new' => 1, 'allow_duplicate' => true);
             foreach ($usersIds as $userId) {
                 if ($answer->isVisible($userId)) {
                     $notification['user_id'] = $userId;
                     bp_notifications_add_notification($notification);
                 }
             }
         }
     }
     wp_safe_redirect(CMA::getReferer());
     exit;
 }
开发者ID:douglaswebdesigns,项目名称:ask-bio-expert,代码行数:27,代码来源:BuddyPress.php

示例15: groups_notification_group_invites

/**
 * Notify a member they have been invited to a group.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param BP_Groups_Group $group Group object.
 * @param BP_Groups_Member $member Member object.
 * @param int $inviter_user_id ID of the user who sent the invite.
 * @return bool|null False on failure.
 */
function groups_notification_group_invites(&$group, &$member, $inviter_user_id)
{
    // Bail if member has already been invited
    if (!empty($member->invite_sent)) {
        return;
    }
    // @todo $inviter_ud may be used for caching, test without it
    $inviter_ud = bp_core_get_core_userdata($inviter_user_id);
    $inviter_name = bp_core_get_userlink($inviter_user_id, true, false, true);
    $inviter_link = bp_core_get_user_domain($inviter_user_id);
    $group_link = bp_get_group_permalink($group);
    // Setup the ID for the invited user
    $invited_user_id = $member->user_id;
    // Trigger a BuddyPress Notification
    if (bp_is_active('notifications')) {
        bp_notifications_add_notification(array('user_id' => $invited_user_id, 'item_id' => $group->id, 'component_name' => buddypress()->groups->id, 'component_action' => 'group_invite'));
    }
    // Bail if member opted out of receiving this email
    if ('no' === bp_get_user_meta($invited_user_id, 'notification_groups_invite', true)) {
        return false;
    }
    $invited_ud = bp_core_get_core_userdata($invited_user_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = bp_core_get_user_domain($invited_user_id) . $settings_slug . '/notifications/';
    $invited_link = bp_core_get_user_domain($invited_user_id);
    $invites_link = trailingslashit($invited_link . bp_get_groups_slug() . '/invites');
    // Set up and send the message
    $to = $invited_ud->user_email;
    $subject = bp_get_email_subject(array('text' => sprintf(__('You have an invitation to the group: "%s"', 'buddypress'), $group->name)));
    $message = sprintf(__('One of your friends %1$s has invited you to the group: "%2$s".

To view your group invites visit: %3$s

To view the group visit: %4$s

To view %5$s\'s profile visit: %6$s

---------------------
', 'buddypress'), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link);
    // Only show the disable notifications line if the settings component is enabled
    if (bp_is_active('settings')) {
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
    }
    // Send the message
    $to = apply_filters('groups_notification_group_invites_to', $to);
    $subject = apply_filters_ref_array('groups_notification_group_invites_subject', array($subject, &$group));
    $message = apply_filters_ref_array('groups_notification_group_invites_message', array($message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link, $settings_link));
    wp_mail($to, $subject, $message);
    do_action('bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group);
}
开发者ID:eresyyl,项目名称:mk,代码行数:60,代码来源:bp-groups-notifications.php


注:本文中的bp_notifications_add_notification函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。