Variable array to another functional variable
-
I have the following PHP function to retrieve some user_ids that I would like to add as recipients for the message, as shown below.
function true_my_bp_get_users_by_xprofile ($ field_id_to_check, $ num_to_find) {
global $ wpdb;$ table_name = $ wpdb-> prefix. “bp_xprofile_data”;
$ user_ids = $ wpdb-> get_results (
$ wpdb-> prepare (
“SELECT user_id FROM $ table_name
WHERE field_id =% d AND value LIKE ‘%% \ “% d \” %%’ “,
$ field_id_to_check,
$ num_to_find
)
);
print_r ($ user_ids);
}
I am using true_my_bp_get_users_by_xprofile (5, 18); which prints Array ([0] => stdClass Object ([user_id] => 1) [1] => stdClass Object ([user_id] => 2))Then I have an HTML form with this code:
$ body_input = isset ($ _ POST [‘body_input’])? $ _ POST [‘body_input’]: ”;
$ subject_input = isset ($ _ POST [‘subject_input’])? $ _ POST [‘subject_input’]: ”;send_msg ($ user_ids, $ body_input, $ subject_input);
Using send_msgfunction send_msg ($ user_id, $ title, $ message) {
$ args = array (‘recipients’ => $ user_id, ‘sender_id’ => bp_loggedin_user_id (), ‘subject’ => $ title, ‘content’ => $ message);
messages_new_message ($ args);
}
What I want to do:Take an array from $ user_ids and place it here: ‘recipients’ => $ user_id
I tried to replace $ user_id with $ user_ids in a function, but it does not work.
- You must be logged in to reply to this topic.