In detail the condition is There are multiple new users to whom admin want to send welcome message but only once for each member. I have done sending message but if the member refresh his email page than the code execute again and new message is send to him by admin and i want to stop sending multiple mail even after he reload his mail page.
$rcvr_id = $wpdb->get_results("SELECT ID FROM wp_users ORDER BY ID "); foreach($rcvr_id as $rv_id) { $rcvr_id = $rv_id->ID;
global $wpdb;
$table_name = $wpdb->prefix . "mail_messages";
$date = date('Y-m-d H:i:s');
$rows = array(
array(
'sender_id' => 4, // who send mail to new members
'receiver_id' => $rcvr_id, // new members who recieve mail just once from sender above
'sent_date' => $date,
'thread_id' => 1,
'subject' => 'Welcome',
'text_message' => 'You are welcome to our world.',
'send_del_message' => 0
)
);
foreach( $rows as $row )
{
$sndr_id = $wpdb->get_results("SELECT sender_id FROM wp_mail_messages ");
//echo $sndr_id;
$wpdb->insert( $table_name, $row);
}
if($sndr_id != 4){
break;
}
}
This is code which send mail to all members but continue sending on each refresh of page by receiver.