Insert private message details into another table
-
Hello, I want to insert the private message details into another table. I managed to do it by using “bp_after_message_thread_list” hook but the problem here is whenever I refresh the page once again the entry is made into to the table. This is what I need to avoid. How can this be done. Here is my code what I have tried just need to avoid page refresh thing.
function insert_buddypress_message_first(){ global $wpdb, $thread_template; $from = bp_loggedin_user_id(); $recipients = $thread_template->thread->recipients; $msg = end($thread_template->thread->messages); foreach ($recipients as $key => $value) { if($recipients[$key]->user_id != $from){ $to = $recipients[$key]->user_id; $sql = ("INSERT INTO private_backup(<code>from</code>,<code>to</code>,<code>message</code>) VALUES ('".$from."','".$to."','".$msg->message."')"); $wpdb->query($sql); } } } add_action( 'bp_after_message_thread_list', 'insert_buddypress_message_first');
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Insert private message details into another table’ is closed to new replies.