我已经尝试搜索上述内容并找到了类似的结果,但不能解决我的问题。我有一个 WP 主题,其中包括在用户之间发送私人消息的功能,接收者会收到收到私人消息的电子邮件通知。问题是消息被发送了两次,电子邮件也是如此。我也可以在收件箱和发件箱中看到两次消息。
这是代码,不确定是什么导致了问题:
<?php }
elseif($third_page == 'send') { ?>
<?php
$pid = $_GET['pid'];
$uid = $_GET['uid'];
$user = get_userdata($uid);
if(!empty($pid))
{
$post = get_post($pid);
$subject = "RE: ".$post->post_title;
}
if(isset($_POST['send']))
{
$subject = strip_tags(trim($_POST['subject']));
$message = strip_tags(trim($_POST['message']));
$to = $_POST['to'];
if(!empty($to))
{
$uid = auctionTheme_get_userid_from_username($to);
}
if($uid != false && $current_user->ID != $uid):
global $current_user;
get_currentuserinfo();
$myuid = $current_user->ID;
global $wpdb; $tm = current_time('timestamp',0);
$s = "insert into ".$wpdb->prefix."auction_pm (subject, content, datemade, pid, initiator, user) values('$subject','$message','$tm','$pid','$myuid','$uid')";
//mysql_query($s) or die(mysql_error());
// $wpdb->show_errors = true;
$wpdb->query($s);
//echo $wpdb->last_error;
//-----------------------
$user = get_userdata($uid);
AuctionTheme_send_email_on_priv_mess_received($myuid, $uid)
//-----------------------
?>
<div class="my_box3">
<div class="padd10">
<?php _e('Your message has been sent.','AuctionTheme'); ?>
</div>
</div>
<?php
elseif($current_user->ID == $uid):
?>
<div class="error">
<?php _e('Cant send messsages to yourself','AuctionTheme'); ?>
</div>
<?php
else:
?>
<div class="my_box3">
<div class="padd10">
<?php _e('The message was not sent. The recipient does not exist.','AuctionTheme'); ?>
</div>
</div>
<?php
endif;
}
else
{
?>
<div class="my_box3">
<div class="padd10">
<div class="box_title"><?php echo sprintf(__("Send Private Message to: %s","AuctionTheme"), $user->user_login); ?></div>
<div class="box_content">
<form method="post" enctype="application/x-www-form-urlencoded">
<table>
<?php if(empty($uid)): ?>
<tr>
<td width="140"><?php _e("Send To", "AuctionTheme"); ?>:</td>
<td><input size="20" name="to" type="text" value="" /></td>
</tr>
<?php endif; ?>
<tr>
<td width="140"><?php _e("Subject", "AuctionTheme"); ?>:</td>
<td><input size="50" name="subject" type="text" value="<?php echo $subject; ?>" /></td>
</tr>
<tr>
<td valign="top"><?php _e("Message", "AuctionTheme"); ?>:</td>
<td><textarea name="message" rows="6" cols="50"></textarea></td>
</tr>
<tr>
<td width="140"> </td>
<td></td>
</tr>
<tr>
<td width="140"> </td>
<td><input name="send" type="submit" value="<?php _e("Send Message",'AuctionTheme'); ?>" /></td>
</tr>
</table>
</form>
</div>
</div>
</div>
<?php } } ?>
</div>
我尝试通过删除/添加“//”来处理代码的最后一点,有些导致发送了电子邮件但没有发送消息,有些导致发送了 4 次消息,但也没有解决问题。
多谢你们