Changeset 2287 for trunk/bp-xprofile/bp-xprofile-notifications.php
- Timestamp:
- 01/10/2010 08:42:42 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-xprofile/bp-xprofile-notifications.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-notifications.php
r2218 r2287 1 1 <?php 2 3 function xprofile_at_message_notification( $content, $poster_user_id, $activity_id ) {4 global $bp;5 6 /* Scan for @username strings in an activity update. Notify each user. */7 $pattern = '/[@]+([A-Za-z0-9-_]+)/';8 preg_match_all( $pattern, $content, $usernames );9 10 /* Make sure there's only one instance of each username */11 if ( !$usernames = array_unique( $usernames[1] ) )12 return false;13 14 foreach( (array)$usernames as $username ) {15 if ( !$receiver_user_id = bp_core_get_userid($username) )16 continue;17 18 // Add a screen notification of an @message19 bp_core_add_notification( $activity_id, $receiver_user_id, $bp->profile->id, 'new_at_mention', $poster_user_id );20 21 // Now email the user with the contents of the message (if they have enabled email notifications)22 if ( !get_usermeta( $user_id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $user_id, 'notification_activity_new_mention' ) ) {23 $poster_name = bp_core_get_user_displayname( $poster_user_id );24 25 $message_link = bp_activity_get_permalink( $activity_id );26 $settings_link = bp_core_get_user_domain( $user_id ) . 'settings/notifications/';27 28 // Set up and send the message29 $ud = get_userdata( $receiver_user_id );30 $to = $ud->user_email;31 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), stripslashes($poster_name) );32 33 $message = sprintf( __(34 '%s mentioned you in an update:35 36 "%s"37 38 To view and respond to the message, log in and visit: %s39 40 ---------------------41 ', 'buddypress' ), $poster_name, wp_filter_kses( stripslashes($content) ), $message_link );42 43 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );44 45 // Send it46 wp_mail( $to, $subject, $message );47 }48 }49 }50 add_action( 'xprofile_posted_update', 'xprofile_at_message_notification', 10, 3 );51 2 52 3 /**
Note: See TracChangeset
for help on using the changeset viewer.