Changeset 10286 for trunk/src/bp-messages/bp-messages-functions.php
- Timestamp:
- 10/19/2015 07:47:01 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-messages/bp-messages-functions.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-functions.php
r10139 r10286 17 17 /** 18 18 * Create a new message. 19 * 20 * @since 2.4.0 Added 'error_type' as an additional $args parameter. 19 21 * 20 22 * @param array|string $args { … … 32 34 * @type string $content Content of the message. Cannot be empty. 33 35 * @type string $date_sent Date sent, in 'Y-m-d H:i:s' format. Default: current date/time. 36 * @type string $error_type Optional. Error type. Either 'bool' or 'wp_error'. Default: 'bool'. 34 37 * } 35 38 * @return int|bool ID of the message thread on success, false on failure. … … 44 47 'subject' => false, 45 48 'content' => false, 46 'date_sent' => bp_core_current_time() 49 'date_sent' => bp_core_current_time(), 50 'error_type' => 'bool' 47 51 ), 'messages_new_message' ); 48 52 49 53 // Bail if no sender or no content 50 54 if ( empty( $r['sender_id'] ) || empty( $r['content'] ) ) { 51 return false; 55 if ( 'wp_error' === $r['error_type'] ) { 56 if ( empty( $r['sender_id'] ) ) { 57 $error_code = 'messages_empty_sender'; 58 $feedback = __( 'Your message was not sent. Please use a valid sender.', 'buddypress' ); 59 } else { 60 $error_code = 'messages_empty_content'; 61 $feedback = __( 'Your message was not sent. Please enter some content.', 'buddypress' ); 62 } 63 64 return new WP_Error( $error_code, $feedback ); 65 66 } else { 67 return false; 68 } 52 69 } 53 70 … … 83 100 // Bail if no recipients 84 101 if ( empty( $r['recipients'] ) ) { 85 return false; 102 if ( 'wp_error' === $r['error_type'] ) { 103 return new WP_Error( 'message_empty_recipients', __( 'Message could not be sent. Please enter a recipient.', 'buddypress' ) ); 104 } else { 105 return false; 106 } 86 107 } 87 108 … … 139 160 $recipient_ids = array_unique( $recipient_ids ); 140 161 if ( empty( $recipient_ids ) ) { 141 return false; 162 if ( 'wp_error' === $r['error_type'] ) { 163 return new WP_Error( 'message_invalid_recipients', __( 'Message could not be sent because you have entered an invalid username. Please try again.', 'buddypress' ) ); 164 } else { 165 return false; 166 } 142 167 } 143 168
Note: See TracChangeset
for help on using the changeset viewer.