Changeset 2218 for trunk/bp-xprofile/bp-xprofile-notifications.php
- Timestamp:
- 12/27/2009 08:01:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-notifications.php
r2077 r2218 1 1 <?php 2 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 @message 19 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 message 29 $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: %s 39 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 it 46 wp_mail( $to, $subject, $message ); 47 } 48 } 49 } 50 add_action( 'xprofile_posted_update', 'xprofile_at_message_notification', 10, 3 ); 51 3 52 /** 4 * xprofile_record_wire_post_notification() 53 * xprofile_record_wire_post_notification() [DEPRECATED] 5 54 * 6 55 * Records a notification for a new profile wire post to the database and sends out a notification
Note: See TracChangeset
for help on using the changeset viewer.