diff --git src/bp-messages/actions/compose.php src/bp-messages/actions/compose.php
index 01701d1fc..0c39ed2af 100644
|
|
|
function bp_messages_action_create_message() {
|
| 29 | 29 | $feedback = ''; |
| 30 | 30 | $success = false; |
| 31 | 31 | |
| 32 | | // Missing subject or content. |
| 33 | | if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) { |
| 34 | | $success = false; |
| | 32 | // Setup the link to the logged-in user's messages. |
| | 33 | $path_chunks = array( bp_get_messages_slug() ); |
| | 34 | |
| | 35 | // Missing usernames or friend's name |
| | 36 | if ( empty( $_POST['send_to_usernames'] ) ) { |
| | 37 | $success = false; |
| | 38 | |
| | 39 | $path_chunks[] = 'compose'; |
| | 40 | |
| | 41 | $feedback = __( 'Your message was not sent. Please enter a username or Friend\'s name.', 'buddypress' ); |
| | 42 | |
| | 43 | $redirect_to = bp_loggedin_user_url( bp_members_get_path_chunks( $path_chunks ) ); |
| | 44 | |
| | 45 | // Missing subject or content. |
| | 46 | } elseif ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) { |
| | 47 | $success = false; |
| | 48 | |
| | 49 | $path_chunks[] = 'compose'; |
| 35 | 50 | |
| 36 | 51 | if ( empty( $_POST['subject'] ) ) { |
| 37 | 52 | $feedback = __( 'Your message was not sent. Please enter a subject line.', 'buddypress' ); |
| … |
… |
function bp_messages_action_create_message() {
|
| 39 | 54 | $feedback = __( 'Your message was not sent. Please enter some content.', 'buddypress' ); |
| 40 | 55 | } |
| 41 | 56 | |
| 42 | | // Subject and content present. |
| 43 | | } else { |
| | 57 | $redirect_to = add_query_arg( |
| | 58 | array( |
| | 59 | 'r' => $_POST['send_to_usernames'], |
| | 60 | '_wpnonce' => wp_create_nonce( 'action' ), |
| | 61 | ), |
| | 62 | bp_loggedin_user_url( bp_members_get_path_chunks( $path_chunks ) ) |
| | 63 | ); |
| 44 | 64 | |
| 45 | | // Setup the link to the logged-in user's messages. |
| 46 | | $path_chunks = array( bp_get_messages_slug() ); |
| | 65 | // Subject and content present. |
| | 66 | } else { |
| 47 | 67 | |
| 48 | 68 | // Site-wide notice. |
| 49 | 69 | if ( isset( $_POST['send-notice'] ) ) { |
| … |
… |
function bp_messages_action_create_message() {
|
| 55 | 75 | $path_chunks[] = 'notices'; |
| 56 | 76 | $redirect_to = bp_loggedin_user_url( bp_members_get_path_chunks( $path_chunks ) ); |
| 57 | 77 | |
| 58 | | // Notice could not be sent. |
| | 78 | // Notice could not be sent. |
| 59 | 79 | } else { |
| 60 | 80 | $success = false; |
| 61 | 81 | $feedback = __( 'Notice was not created. Please try again.', 'buddypress' ); |
| 62 | 82 | } |
| 63 | 83 | |
| 64 | | // Private conversation. |
| | 84 | // Private conversation. |
| 65 | 85 | } else { |
| 66 | 86 | |
| 67 | 87 | // Filter recipients into the format we need - array( 'username/userid', 'username/userid' ). |
| … |
… |
function bp_messages_action_create_message() {
|
| 79 | 99 | $recipients = apply_filters( 'bp_messages_recipients', $recipients ); |
| 80 | 100 | |
| 81 | 101 | // Attempt to send the message. |
| 82 | | $send = messages_new_message( array( |
| 83 | | 'recipients' => $recipients, |
| 84 | | 'subject' => $_POST['subject'], |
| 85 | | 'content' => $_POST['content'], |
| 86 | | 'error_type' => 'wp_error', |
| 87 | | ) ); |
| | 102 | $send = messages_new_message( |
| | 103 | array( |
| | 104 | 'recipients' => $recipients, |
| | 105 | 'subject' => $_POST['subject'], |
| | 106 | 'content' => $_POST['content'], |
| | 107 | 'error_type' => 'wp_error', |
| | 108 | ) |
| | 109 | ); |
| 88 | 110 | |
| 89 | 111 | // Send the message and redirect to it. |
| 90 | 112 | if ( true === is_int( $send ) ) { |
| … |
… |
function bp_messages_action_create_message() {
|
| 94 | 116 | $path_chunks[] = array( $send ); |
| 95 | 117 | $redirect_to = bp_loggedin_user_url( bp_members_get_path_chunks( $path_chunks ) ); |
| 96 | 118 | |
| 97 | | // Message could not be sent. |
| | 119 | // Message could not be sent. |
| 98 | 120 | } else { |
| 99 | 121 | $success = false; |
| 100 | 122 | $feedback = $send->get_error_message(); |