上記を検索してみましたが、同様の結果が見つかりましたが、問題を解決できませんでした。ユーザー間でプライベート メッセージを送信する機能を含む WP テーマがあります。受信者は、プライベート メッセージが受信されたという電子メール通知を受け取ります。問題は、メッセージが 2 回送信され、電子メールも送信されることです。受信トレイと送信トレイにもメッセージが 2 回表示されます。
ここにコードがありますが、何が問題を引き起こしているのかわかりません:
<?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回送信されたものもありましたが、問題を解決するものはありませんでした。
みんなありがとう