function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    $friend_name = bp_core_get_user_displayname($friend_id);
    if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
        return false;
    }
    $ud = get_userdata($initiator_id);
    $friend_link = bp_core_get_user_domain($friend_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = trailingslashit(bp_core_get_user_domain($initiator_id) . $settings_slug . '/notifications');
    // Set up and send the message
    $to = $ud->user_email;
    $subject = bp_get_email_subject(array('text' => sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name)));
    $message = sprintf(__('%1$s accepted your friend request.

To view %2$s\'s profile: %3$s

---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_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('friends_notification_accepted_request_to', $to);
    $subject = apply_filters('friends_notification_accepted_request_subject', $subject, $friend_name);
    $message = apply_filters('friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link);
    wp_mail($to, $subject, $message);
    do_action('bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id);
}
function messages_notification_new_message($args = array())
{
    // These should be extracted below
    $recipients = array();
    $email_subject = $email_content = '';
    extract($args);
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Bail if no recipients
    if (!empty($recipients)) {
        foreach ($recipients as $recipient) {
            if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
                continue;
            }
            // User data and links
            $ud = get_userdata($recipient->user_id);
            // Bail if user cannot be found
            if (empty($ud)) {
                continue;
            }
            $message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
            $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
            $settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
            // Sender info
            $sender_name = stripslashes($sender_name);
            $subject = stripslashes(wp_filter_kses($subject));
            $content = stripslashes(wp_filter_kses($content));
            // Set up and send the message
            $email_to = $ud->user_email;
            $email_subject = bp_get_email_subject(array('text' => sprintf(__('New message from %s', 'buddypress'), $sender_name)));
            $email_content = sprintf(__('%1$s sent you a new message:

Subject: %2$s

"%3$s"

To view and read your messages please log in and visit: %4$s

---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
            // Only show the disable notifications line if the settings component is enabled
            if (bp_is_active('settings')) {
                $email_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            }
            // Send the message
            $email_to = apply_filters('messages_notification_new_message_to', $email_to);
            $email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name);
            $email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link);
            wp_mail($email_to, $email_subject, $email_content);
        }
    }
    do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
/**
 * Email message recipients to alert them of a new unread private message.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param array|BP_Messages_Message $raw_args {
 *     Array of arguments. Also accepts a BP_Messages_Message object.
 *     @type array  $recipients    User IDs of recipients.
 *     @type string $email_subject Subject line of message.
 *     @type string $email_content Content of message.
 *     @type int    $sender_id     User ID of sender.
 * }
 */
function messages_notification_new_message($raw_args = array())
{
    // Cast possible $message object as an array
    if (is_object($raw_args)) {
        $args = (array) $raw_args;
    } else {
        $args = $raw_args;
    }
    // These should be extracted below
    $recipients = array();
    $email_subject = $email_content = '';
    $sender_id = 0;
    // Barf
    extract($args);
    // Get the sender display name
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Bail if no recipients
    if (!empty($recipients)) {
        foreach ($recipients as $recipient) {
            if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
                continue;
            }
            // User data and links
            $ud = get_userdata($recipient->user_id);
            // Bail if user cannot be found
            if (empty($ud)) {
                continue;
            }
            $message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
            $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
            $settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
            // Sender info
            $sender_name = stripslashes($sender_name);
            $subject = stripslashes(wp_filter_kses($subject));
            $content = stripslashes(wp_filter_kses($message));
            // Set up and send the message
            $email_to = $ud->user_email;
            $email_subject = bp_get_email_subject(array('text' => sprintf(__('New message from %s', 'buddypress'), $sender_name)));
            $email_content = sprintf(__('%1$s sent you a new message:

Subject: %2$s

"%3$s"

To view and read your messages please log in and visit: %4$s

---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
            // Only show the disable notifications line if the settings component is enabled
            if (bp_is_active('settings')) {
                $email_content .= sprintf(__('To disable these notifications, please log in and go to: %s', 'buddypress'), $settings_link);
            }
            /**
             * Filters the user email that the message notification will be sent to.
             *
             * @since BuddyPress (1.2.0)
             *
             * @param string  $email_to User email the notification is being sent to.
             * @param WP_User $ud       WP_User object of who is receiving the message.
             */
            $email_to = apply_filters('messages_notification_new_message_to', $email_to, $ud);
            /**
             * Filters the message notification subject that will be sent to user.
             *
             * @since BuddyPress (1.2.0)
             *
             * @param string  $email_subject Email notification subject text.
             * @param string  $sender_name   Name of the person who sent the message.
             * @param WP_User $ud            WP_User object of who is receiving the message.
             */
            $email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name, $ud);
            /**
             * Filters the message notification message that will be sent to user.
             *
             * @since BuddyPress (1.2.0)
             *
             * @param string  $email_content Email notification message text.
             * @param string  $sender_name   Name of the person who sent the message.
             * @param string  $subject       Email notification subject text.
             * @param string  $content       Content of the message.
             * @param string  $message_link  URL permalink for the message.
             * @param string  $settings_link URL permalink for the user's notification settings area.
             * @param WP_User $ud            WP_User object of who is receiving the message.
             */
            $email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link, $ud);
            wp_mail($email_to, $email_subject, $email_content);
        }
    }
    /**
     * Fires after the sending of a new message email notification.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param array  $recipients    User IDs of recipients.
     * @param string $email_subject Email notification subject text.
     * @param string $email_content Email notification message text.
     * @param array  $$args         Array of originally provided arguments.
     */
    do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
/**
 * Send email and BP notifications when an activity item receives a comment.
 *
 * @since 1.2.0
 *
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses wp_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_get_root_blog_id()
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook.
 * @uses wp_mail()
 * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook.
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook.
 * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook.
 *
 * @param int   $comment_id   The comment id.
 * @param int   $commenter_id The ID of the user who posted the comment.
 * @param array $params       {@link bp_activity_new_comment()}.
 * @return bool
 */
function bp_activity_new_comment_notification($comment_id = 0, $commenter_id = 0, $params = array())
{
    // Set some default parameters.
    $activity_id = 0;
    $parent_id = 0;
    extract($params);
    $original_activity = new BP_Activity_Activity($activity_id);
    if ($original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta($original_activity->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($original_activity->user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        // Set up and send the message.
        $ud = bp_core_get_core_userdata($original_activity->user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your updates', 'buddypress'), $poster_name)));
        $message = sprintf(__('%1$s replied to one of your updates:

"%2$s"

To view your original update and all comments, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_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);
        }
        /**
         * Filters the user email that the new comment notification will be sent to.
         *
         * @since 1.2.0
         *
         * @param string $to User email the notification is being sent to.
         */
        $to = apply_filters('bp_activity_new_comment_notification_to', $to);
        /**
         * Filters the new comment notification subject that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $subject     Email notification subject text.
         * @param string $poster_name Name of the person who made the comment.
         */
        $subject = apply_filters('bp_activity_new_comment_notification_subject', $subject, $poster_name);
        /**
         * Filters the new comment notification message that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $message       Email notification message text.
         * @param string $poster_name   Name of the person who made the comment.
         * @param string $content       Content of the comment.
         * @param string $thread_link   URL permalink for the activity thread.
         * @param string $settings_link URL permalink for the user's notification settings area.
         */
        $message = apply_filters('bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link);
        wp_mail($to, $subject, $message);
        /**
         * Fires after the sending of a reply to an update email notification.
         *
         * @since 1.5.0
         *
         * @param int    $user_id      ID of the original activity item author.
         * @param string $subject      Email notification subject text.
         * @param string $message      Email notification message text.
         * @param int    $comment_id   ID for the newly received comment.
         * @param int    $commenter_id ID of the user who made the comment.
         * @param array  $params       Arguments used with the original activity comment.
         */
        do_action('bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
    /*
     * If this is a reply to another comment, send an email notification to the
     * author of the immediate parent comment.
     */
    if (empty($parent_id) || $activity_id == $parent_id) {
        return false;
    }
    $parent_comment = new BP_Activity_Activity($parent_id);
    if ($parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta($parent_comment->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($parent_comment->user_id) . $settings_slug . '/notifications/';
        // Set up and send the message.
        $ud = bp_core_get_core_userdata($parent_comment->user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your comments', 'buddypress'), $poster_name)));
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        $message = sprintf(__('%1$s replied to one of your comments:

"%2$s"

To view the original activity, your comment and all replies, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_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);
        }
        /**
         * Filters the user email that the new comment reply notification will be sent to.
         *
         * @since 1.2.0
         *
         * @param string $to User email the notification is being sent to.
         */
        $to = apply_filters('bp_activity_new_comment_notification_comment_author_to', $to);
        /**
         * Filters the new comment reply notification subject that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $subject     Email notification subject text.
         * @param string $poster_name Name of the person who made the comment reply.
         */
        $subject = apply_filters('bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name);
        /**
         * Filters the new comment reply notification message that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $message       Email notification message text.
         * @param string $poster_name   Name of the person who made the comment reply.
         * @param string $content       Content of the comment reply.
         * @param string $settings_link URL permalink for the user's notification settings area.
         * @param string $thread_link   URL permalink for the activity thread.
         */
        $message = apply_filters('bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link);
        wp_mail($to, $subject, $message);
        /**
         * Fires after the sending of a reply to a reply email notification.
         *
         * @since 1.5.0
         *
         * @param int    $user_id      ID of the parent activity item author.
         * @param string $subject      Email notification subject text.
         * @param string $message      Email notification message text.
         * @param int    $comment_id   ID for the newly received comment.
         * @param int    $commenter_id ID of the user who made the comment.
         * @param array  $params       Arguments used with the original activity comment.
         */
        do_action('bp_activity_sent_reply_to_reply_email', $parent_comment->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
}
function groups_notification_group_invites(&$group, &$member, $inviter_user_id)
{
    // @todo $inviter_up 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);
    if (!$member->invite_sent) {
        $invited_user_id = $member->user_id;
        // Post a screen notification first.
        bp_core_add_notification($group->id, $invited_user_id, 'groups', 'group_invite');
        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);
    }
}
/**
 * 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.
 * @return null|false 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);
    }
    /**
     * Filters the user email that the group invite notification will be sent to.
     *
     * @since 1.2.0
     *
     * @param string $to User email the invite notification is being sent to.
     */
    $to = apply_filters('groups_notification_group_invites_to', $to);
    /**
     * Filters the group invite notification subject that will be sent to user.
     *
     * @since 1.2.0
     *
     * @param string          $subject Invite notification email subject text.
     * @param BP_Groups_Group $group   Object holding the current group instance. Passed by reference.
     */
    $subject = apply_filters_ref_array('groups_notification_group_invites_subject', array($subject, &$group));
    /**
     * Filters the group invite notification message that will be sent to user.
     *
     * @since 1.2.0
     *
     * @param string          $message       Invite notification email message text.
     * @param BP_Groups_Group $group         Object holding the current group instance. Passed by reference.
     * @param string          $inviter_name  Username for the person doing the inviting.
     * @param string          $inviter_link  Profile link for the person doing the inviting.
     * @param string          $invites_link  URL permalink for the invited user's invite management screen.
     * @param string          $group_link    URL permalink for the group that the invite was related to.
     * @param string          $settings_link URL permalink for the user's notification settings area.
     */
    $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);
    /**
     * Fires after the notification is sent that a member has been invited to a group.
     *
     * @since 1.5.0
     *
     * @param int             $invited_user_id  ID of the user who was invited.
     * @param string          $subject          Email notification subject text.
     * @param string          $message          Email notification message text.
     * @param BP_Groups_Group $group            Group object.
     */
    do_action('bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group);
}
예제 #7
0
/**
 * Notify new users of a successful registration (without blog).
 *
 * @see wpmu_signup_user_notification() for a full description of params.
 *
 * @param string $user The user's login name.
 * @param string $user_email The user's email address.
 * @param string $key The activation key created in wpmu_signup_user()
 * @param array $meta By default, an empty array.
 * @return bool True on success, false on failure.
 */
function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {

	if ( is_admin() ) {
		// If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications
		if( in_array( get_current_screen()->id, array( 'user', 'user-network' ) ) ) {
			// If the Super Admin want to skip confirmation email
			if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
				return false;

			// WordPress will manage the signup process
			} else {
				return $user;
			}

		/**
		 * There can be a case where the user was created without the skip confirmation
		 * And the super admin goes in pending accounts to resend it. In this case, as the
		 * meta['password'] is not set, the activation url must be WordPress one
		 */
		} elseif ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
			$is_hashpass_in_meta = maybe_unserialize( $meta );

			if ( empty( $is_hashpass_in_meta['password'] ) ) {
				return $user;
			}
		}
	}

	// Set up activation link
	$activate_url = bp_get_activation_page() . "?key=$key";
	$activate_url = esc_url( $activate_url );

	// Email contents
	$message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url );
	$subject = bp_get_email_subject( array( 'text' => __( 'Activate Your Account', 'buddypress' ) ) );

	// Email filters
	$to      = apply_filters( 'bp_core_activation_signup_user_notification_to',   $user_email, $user, $user_email, $key, $meta );
	$subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta );
	$message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta );

	// Send the email
	wp_mail( $to, $subject, $message );

	// Set up the $admin_email to pass to the filter
	$admin_email = bp_get_option( 'admin_email' );

	do_action( 'bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta );

	// Return false to stop the original WPMU function from continuing
	return false;
}
/**
 * Notify new users of a successful registration (without blog).
 *
 * @see wpmu_signup_user_notification() for a full description of params.
 *
 * @param string $user       The user's login name.
 * @param string $user_email The user's email address.
 * @param string $key        The activation key created in wpmu_signup_user()
 * @param array  $meta       By default, an empty array.
 *
 * @return bool|string True on success, false on failure.
 */
function bp_core_activation_signup_user_notification($user, $user_email, $key, $meta)
{
    if (is_admin()) {
        // If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications
        if (in_array(get_current_screen()->id, array('user', 'user-network'))) {
            // If the Super Admin want to skip confirmation email
            if (isset($_POST['noconfirmation']) && is_super_admin()) {
                return false;
                // WordPress will manage the signup process
            } else {
                return $user;
            }
            /**
             * There can be a case where the user was created without the skip confirmation
             * And the super admin goes in pending accounts to resend it. In this case, as the
             * meta['password'] is not set, the activation url must be WordPress one
             */
        } elseif (buddypress()->members->admin->signups_page == get_current_screen()->id) {
            $is_hashpass_in_meta = maybe_unserialize($meta);
            if (empty($is_hashpass_in_meta['password'])) {
                return $user;
            }
        }
    }
    // Set up activation link
    $activate_url = bp_get_activation_page() . "?key={$key}";
    $activate_url = esc_url($activate_url);
    // Email contents
    $message = sprintf(__("Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress'), $activate_url);
    $subject = bp_get_email_subject(array('text' => __('Activate Your Account', 'buddypress')));
    /**
     * Filters the email that the notification is going to upon successful registration without blog.
     *
     * @since 1.2.0
     *
     * @param string $user_email The user's email address.
     * @param string $user       The user's login name.
     * @param string $user_email The user's email address.
     * @param string $key        The activation key created in wpmu_signup_blog().
     * @param array  $meta       Array of meta values for the created site.
     */
    $to = apply_filters('bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta);
    /**
     * Filters the subject that the notification uses upon successful registration without blog.
     *
     * @since 1.2.0
     *
     * @param string $subject    The subject to use.
     * @param string $user       The user's login name.
     * @param string $user_email The user's email address.
     * @param string $key        The activation key created in wpmu_signup_blog().
     * @param array  $meta       Array of meta values for the created site.
     */
    $subject = apply_filters('bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta);
    /**
     * Filters the message that the notification uses upon successful registration without blog.
     *
     * @since 1.2.0
     *
     * @param string $message    The message to use.
     * @param string $user       The user's login name.
     * @param string $user_email The user's email address.
     * @param string $key        The activation key created in wpmu_signup_blog().
     * @param array  $meta       Array of meta values for the created site.
     */
    $message = apply_filters('bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta);
    // Send the email
    wp_mail($to, $subject, $message);
    // Set up the $admin_email to pass to the filter
    $admin_email = bp_get_option('admin_email');
    /**
     * Fires after the sending of the notification to new users for successful registration without blog.
     *
     * @since 1.5.0
     *
     * @param string $admin_email Admin Email address for the site.
     * @param string $subject     Subject used in the notification email.
     * @param string $message     Message used in the notification email.
     * @param string $user        The user's login name.
     * @param string $user_email  The user's email address.
     * @param string $key         The activation key created in wpmu_signup_blog().
     * @param array  $meta        Array of meta values for the created site. Default empty array.
     */
    do_action('bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta);
    // Return false to stop the original WPMU function from continuing
    return false;
}
예제 #9
0
/**
 * Send an email and a BP notification on receipt of an @-mention in a group
 *
 * @deprecated BuddyPress (1.5)
 * @deprecated Deprecated in favor of the more general bp_activity_at_message_notification()
 */
function groups_at_message_notification($content, $poster_user_id, $group_id, $activity_id)
{
    _deprecated_function(__FUNCTION__, '1.5', 'bp_activity_at_message_notification()');
    /* Scan for @username strings in an activity update. Notify each user. */
    $pattern = '/[@]+([A-Za-z0-9-_\\.@]+)/';
    preg_match_all($pattern, $content, $usernames);
    /* Make sure there's only one instance of each username */
    if (!($usernames = array_unique($usernames[1]))) {
        return false;
    }
    $group = new BP_Groups_Group($group_id);
    foreach ((array) $usernames as $username) {
        if (!($receiver_user_id = bp_core_get_userid($username))) {
            continue;
        }
        /* Check the user is a member of the group before sending the update. */
        if (!groups_is_user_member($receiver_user_id, $group_id)) {
            continue;
        }
        // Now email the user with the contents of the message (if they have enabled email notifications)
        if ('no' != bp_get_user_meta($receiver_user_id, 'notification_activity_new_mention', true)) {
            $poster_name = bp_core_get_user_displayname($poster_user_id);
            $message_link = bp_activity_get_permalink($activity_id);
            $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
            $settings_link = bp_core_get_user_domain($receiver_user_id) . $settings_slug . '/notifications/';
            $poster_name = stripslashes($poster_name);
            $content = bp_groups_filter_kses(stripslashes($content));
            // Set up and send the message
            $ud = bp_core_get_core_userdata($receiver_user_id);
            $to = $ud->user_email;
            $subject = bp_get_email_subject(array('text' => sprintf(__('%1$s mentioned you in the group "%2$s"', 'buddypress'), $poster_name, $group->name)));
            $message = sprintf(__('%1$s mentioned you in the group "%2$s":

"%3$s"

To view and respond to the message, log in and visit: %4$s

---------------------
', 'buddypress'), $poster_name, $group->name, $content, $message_link);
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            /* Send the message */
            $to = apply_filters('groups_at_message_notification_to', $to);
            $subject = apply_filters('groups_at_message_notification_subject', $subject, $group, $poster_name);
            $message = apply_filters('groups_at_message_notification_message', $message, $group, $poster_name, $content, $message_link, $settings_link);
            wp_mail($to, $subject, $message);
        }
    }
    do_action('bp_groups_sent_mention_email', $usernames, $subject, $message, $content, $poster_user_id, $group_id, $activity_id);
}
/**
 * Send notifications related to the acceptance of a friendship request.
 *
 * When a friendship request is accepted, an email and a BP notification are
 * sent to the user who requested the friendship ($initiator_id).
 *
 * @param int $friendship_id ID of the friendship object.
 * @param int $initiator_id  ID of the user who initiated the request.
 * @param int $friend_id     ID of the request recipient.
 * @return bool
 */
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    $friend_name = bp_core_get_user_displayname($friend_id);
    if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
        return false;
    }
    $ud = get_userdata($initiator_id);
    $friend_link = bp_core_get_user_domain($friend_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = trailingslashit(bp_core_get_user_domain($initiator_id) . $settings_slug . '/notifications');
    // Set up and send the message.
    $to = $ud->user_email;
    $subject = bp_get_email_subject(array('text' => sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name)));
    $message = sprintf(__('%1$s accepted your friend request.

To view %2$s\'s profile: %3$s

---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_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);
    }
    /**
     * Filters the email address for whose friend request got accepted.
     *
     * @since 1.2.0
     *
     * @param string $to Email address for whose friend request got accepted.
     */
    $to = apply_filters('friends_notification_accepted_request_to', $to);
    /**
     * Filters the subject for the friend request accepted email.
     *
     * @since 1.2.0
     *
     * @param string $subject     Subject line to be used in friend request accepted email.
     * @param string $friend_name Name of the person who accepted the friendship request.
     */
    $subject = apply_filters('friends_notification_accepted_request_subject', $subject, $friend_name);
    /**
     * Filters the message for the friend request accepted email.
     *
     * @since 1.2.0
     *
     * @param string $message       Message to be used in friend request email.
     * @param string $friend_name   Name of the person who accepted the friendship request.
     * @param string $friend_link   Profile link of person who accepted the friendship request.
     * @param string $settings_link Email recipient's settings management link.
     */
    $message = apply_filters('friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link);
    wp_mail($to, $subject, $message);
    /**
     * Fires after the friend request accepted email is sent.
     *
     * @since 1.5.0
     *
     * @param int    $initiator_id  ID of the friendship requester.
     * @param string $subject       Text for the friend request subject field.
     * @param string $message       Text for the friend request message field.
     * @param int    $friendship_id ID of the friendship object.
     * @param int    $friend_id     ID of the request recipient.
     */
    do_action('bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id);
}
function bp_core_signup_send_validation_email($user_id, $user_email, $key)
{
    $activate_url = bp_get_activation_page() . "?key={$key}";
    $activate_url = esc_url($activate_url);
    $message = sprintf(__("Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress'), $activate_url);
    $subject = bp_get_email_subject(array('text' => __('Activate Your Account', 'buddypress')));
    // Send the message
    $to = apply_filters('bp_core_signup_send_validation_email_to', $user_email, $user_id);
    $subject = apply_filters('bp_core_signup_send_validation_email_subject', $subject, $user_id);
    $message = apply_filters('bp_core_signup_send_validation_email_message', $message, $user_id, $activate_url);
    wp_mail($to, $subject, $message);
    do_action('bp_core_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key);
}
예제 #12
0
/**
 * Send activation email to a newly registered user.
 *
 * @param int $user_id ID of the new user.
 * @param string $user_email Email address of the new user.
 * @param string $key Activation key.
 */
function bp_core_signup_send_validation_email($user_id, $user_email, $key)
{
    $activate_url = trailingslashit(bp_get_activation_page()) . "{$key}/";
    $activate_url = esc_url($activate_url);
    $message = sprintf(__("Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress'), $activate_url);
    $subject = bp_get_email_subject(array('text' => __('Activate Your Account', 'buddypress')));
    /**
     * Filters the user email that the validation email will be sent to.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param string $user_email User email the notification is being sent to.
     * @param int    $user_id    ID of the new user receiving email.
     */
    $to = apply_filters('bp_core_signup_send_validation_email_to', $user_email, $user_id);
    /**
     * Filters the validation email subject that will be sent to user.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param string $subject Email validation subject text.
     * @param int    $user_id ID of the new user receiving email.
     */
    $subject = apply_filters('bp_core_signup_send_validation_email_subject', $subject, $user_id);
    /**
     * Filters the validation email message that will be sent to user.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param string $message      Email validation message text.
     * @param int    $user_id      ID of the new user receiving email.
     * @param string $activate_url URL to use for activating account.
     */
    $message = apply_filters('bp_core_signup_send_validation_email_message', $message, $user_id, $activate_url);
    wp_mail($to, $subject, $message);
    /**
     * Fires after the sending of activation email to a newly registered user.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param string $subject    Subject for the sent email.
     * @param string $message    Message for the sent email.
     * @param int    $user_id    ID of the new user.
     * @param string $user_email Email address of the new user.
     * @param string $key        Activation key.
     */
    do_action('bp_core_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key);
}
예제 #13
0
/**
 * Notify new users of a successful registration (without blog).
 *
 * @see wpmu_signup_user_notification() for a full description of params.
 *
 * @param string $user The user's login name.
 * @param string $user_email The user's email address.
 * @param string $key The activation key created in wpmu_signup_user()
 * @param array $meta By default, an empty array.
 * @return bool True on success, false on failure.
 */
function bp_core_activation_signup_user_notification($user, $user_email, $key, $meta)
{
    // Set up activation link
    $activate_url = bp_get_activation_page() . "?key={$key}";
    $activate_url = esc_url($activate_url);
    // Email contents
    $message = sprintf(__("Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress'), $activate_url);
    $subject = bp_get_email_subject(array('text' => __('Activate Your Account', 'buddypress')));
    // Email filters
    $to = apply_filters('bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta);
    $subject = apply_filters('bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta);
    $message = apply_filters('bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta);
    // Send the email
    wp_mail($to, $subject, $message);
    // Set up the $admin_email to pass to the filter
    $admin_email = bp_get_option('admin_email');
    do_action('bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta);
    // Return false to stop the original WPMU function from continuing
    return false;
}
/**
 * Sends an email notification and a BP notification when someone mentions you in an update
 *
 * @since BuddyPress (1.2)
 *
 * @param int $comment_id The comment id
 * @param int $commenter_id The unique user_id of the user who posted the comment
 * @param array $params {@link bp_activity_new_comment()}
 *
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses wp_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_get_root_blog_id()
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook
 * @uses wp_mail()
 * @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook
 * @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook
 * @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook
 */
function bp_activity_new_comment_notification($comment_id, $commenter_id, $params)
{
    // Set some default parameters
    $activity_id = 0;
    $parent_id = 0;
    extract($params);
    $original_activity = new BP_Activity_Activity($activity_id);
    if ($original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta($original_activity->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($original_activity->user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        // Set up and send the message
        $ud = bp_core_get_core_userdata($original_activity->user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your updates', 'buddypress'), $poster_name)));
        $message = sprintf(__('%1$s replied to one of your updates:

"%2$s"

To view your original update and all comments, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_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('bp_activity_new_comment_notification_to', $to);
        $subject = apply_filters('bp_activity_new_comment_notification_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link);
        wp_mail($to, $subject, $message);
        do_action('bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
    /***
     * If this is a reply to another comment, send an email notification to the
     * author of the immediate parent comment.
     */
    if (empty($parent_id) || $activity_id == $parent_id) {
        return false;
    }
    $parent_comment = new BP_Activity_Activity($parent_id);
    if ($parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta($parent_comment->user_id, 'notification_activity_new_reply', true)) {
        $poster_name = bp_core_get_user_displayname($commenter_id);
        $thread_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($parent_comment->user_id) . $settings_slug . '/notifications/';
        // Set up and send the message
        $ud = bp_core_get_core_userdata($parent_comment->user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your comments', 'buddypress'), $poster_name)));
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(stripslashes($content));
        $message = sprintf(__('%1$s replied to one of your comments:

"%2$s"

To view the original activity, your comment and all replies, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $thread_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('bp_activity_new_comment_notification_comment_author_to', $to);
        $subject = apply_filters('bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link);
        wp_mail($to, $subject, $message);
        do_action('bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params);
    }
}
function bp_core_activation_signup_user_notification($user, $user_email, $key, $meta)
{
    $activate_url = bp_get_activation_page() . "?key={$key}";
    $activate_url = esc_url($activate_url);
    $admin_email = get_site_option('admin_email');
    if (empty($admin_email)) {
        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    }
    $from_name = bp_get_option('blogname', 'WordPress');
    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    $message = sprintf(__("Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress'), $activate_url);
    $subject = bp_get_email_subject(array('text' => __('Activate Your Account', 'buddypress')));
    // Send the message
    $to = apply_filters('bp_core_activation_signup_user_notification_to', $user_email, $user, $user_email, $key, $meta);
    $subject = apply_filters('bp_core_activation_signup_user_notification_subject', $subject, $user, $user_email, $key, $meta);
    $message = apply_filters('bp_core_activation_signup_user_notification_message', $message, $user, $user_email, $key, $meta);
    wp_mail($to, $subject, $message, $message_headers);
    do_action('bp_core_sent_user_signup_email', $admin_email, $subject, $message, $user, $user_email, $key, $meta);
    // Return false to stop the original WPMU function from continuing
    return false;
}
/**
 * Send a screen notifications & email one when an attendee set his preferences
 *
 * @package Rendez Vous
 * @subpackage Notifications
 *
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_notify_organizer($args = array(), $attendee_id = 0, $rendez_vous = null)
{
    $bp = buddypress();
    if (empty($attendee_id) || empty($rendez_vous) || $attendee_id == $rendez_vous->organizer) {
        return;
    }
    // Screen Notification
    bp_notifications_add_notification(array('user_id' => $rendez_vous->organizer, 'item_id' => $rendez_vous->id, 'secondary_item_id' => $attendee_id, 'component_name' => $bp->rendez_vous->id, 'component_action' => 'rendez_vous_schedule'));
    // Sending Emails
    if ('no' == get_user_meta($rendez_vous->organizer, 'notification_rendez_vous_schedule', true)) {
        return;
    }
    $rendez_vous_link = rendez_vous_get_single_link($rendez_vous->id, $rendez_vous->organizer);
    $rendez_vous_title = stripslashes($rendez_vous->title);
    $rendez_vous_content = wp_kses($rendez_vous_title, array());
    $attendee_name = bp_core_get_user_displayname($attendee_id);
    $attendee_name = stripslashes($attendee_name);
    $organizer_settings = false;
    $organizer_profile = bp_core_get_user_domain($rendez_vous->organizer);
    $organizer_email = bp_core_get_user_email($rendez_vous->organizer);
    $message = sprintf(__("%s set their preferences for the rendez-vous: %s\n\nTo view details, log in and visit: %s\n\n---------------------\n", 'rendez-vous'), $attendee_name, $rendez_vous_content, esc_url($rendez_vous_link));
    $subject = bp_get_email_subject(array('text' => sprintf(__('%s selected date(s) for a rendez-vous', 'rendez-vous'), $attendee_name)));
    // Set up and send the message
    $to = $organizer_email;
    // Only show the disable notifications line if the settings component is enabled
    if (bp_is_active('settings')) {
        $organizer_settings = trailingslashit($organizer_profile . bp_get_settings_slug() . '/notifications');
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'rendez-vous'), esc_url($organizer_settings));
    }
    /* Send the message */
    $to = apply_filters('rendez_vous_userset_notify_organizer', $to);
    $subject = apply_filters('rendez_vous_userset_notify_subject', $subject, $attendee_name);
    $mail_content = apply_filters('rendez_vous_userset_notify_message', $message, $rendez_vous, $attendee_name, $rendez_vous_content, $rendez_vous_link, $organizer_settings);
    wp_mail($to, $subject, $mail_content);
}