在这里,我在wordpress的admin中创建了一个复选框,当我检查并更新它时,它会向用户发送邮件,但每次更新配置文件的任何部分时,它都会发送邮件。有没有办法只发送一次邮件?
此外,我在这里有一个属性列表,当用户请求任何它显示在后端的条目时,当管理员批准时,它应该为用户的每个pdf批准发送电子邮件。所以,当管理员批准任何pdf时,它会通知用户。但在这一刻,它并没有发生。每次我更新个人资料时,它都会发出电子邮件。
add_action( \'show_user_profile\', \'add_extra_profile\' );
add_action( \'edit_user_profile\', \'add_extra_profile\' );
function add_extra_profile(){
global $pagenow;
if($pagenow == \'profile.php\'){
$us_id = get_current_user_id();
}
else{
$us_id = $_GET[\'user_id\'];
}
$deal_meta = get_user_meta($us_id, \'_userdeal\');
$boro_meta = get_user_meta($us_id, \'_borrowerdata\');
$boro_status = get_user_meta($us_id, \'_userformstatus\');
$termsheet_meta = get_user_meta($us_id, \'_usertermsheet\');
$approve_termsheet_meta= get_user_meta($us_id, \'_approvaltermsheet\');
$get_boro =unserialize(base64_decode($boro_meta[0]));
/*----------Termsheet Form------------------*/
$expd= explode(",",$termsheet_meta[0]);
if(!empty($termsheet_meta[0])){
echo "<table border=\'1\' >";
echo "<tbody><tr><th style=\'padding:10px;\'><label>List Of Termsheet Applied For</label></th>
<th style=\'padding:10px;\'><label>Approval<label></th>
</tr>";
echo "<tr>";
for($i=0;$i<count($expd);$i++):
$post_d = get_post($expd[$i]);
$title = $post_d->post_title;
echo "<td style=\'padding:10px;\'><a href=".get_permalink($expd[$i] ).">".$title."</a></td>
<td style=\'padding:10px;\' >";
if(!empty($approve_termsheet_meta[0]) &&in_array($expd[$i],$approve_termsheet_meta[0])){
echo "<input type=\'checkbox\' name=\'approve_termsheet[]\' value=".$expd[$i]." checked />";
}
else{
echo "<input type=\'checkbox\' name=\'approve_termsheet[]\' value=".$expd[$i]." />";
}
echo "</td>";
if( $i % 1== 0 ) {
echo "</tr><tr>";
}
endfor;
echo "</tr>";
echo "</tbody>";
echo "</table>";
//print_r($_REQUEST[\'approve_termsheet\']);
$user_info = get_userdata($us_id );
$subject = \'User Approval\';
$to=$user_info->user_email;
$body = "Your Property Termsheet is Appoved For Download.</br> You Can Login And Download It" ;
add_filter(\'wp_mail_content_type\',create_function(\'\', \'return "text/html"; \'));
$mailSent = get_user_meta($us_id, \'mail_sent\', true);
if($mailSent){
update_user_meta($us_id, \'mail_sent\', \'mail sent\');
}else{
$borrower_mail=wp_mail($to, $subject, $body);
}
}