如何使用引号将wordpress发布在作者电子邮件中

时间:2014-04-04 06:16:10

标签: php wordpress email

我正试图在#34; myeamil@live.com"在single.php页面上。

实际上,我想发送电子邮件给发布此帖子的作者。

我正在使用wp_mail函数从single.php页面向作者发送电子邮件。

这是我正在使用的变量,但它正在收到管理员电子邮件。

$emailTo = get_option('admin_email');

我想要发布帖子的作者电子邮件,而不是管理员电子邮件。我需要帮助。非常感谢。

更新

这是我正在尝试的代码

  

if(!isset($ hasError)){// $ emailTo =" w_chand@live.com" ;;如果   (!isset($ emailTo)||($ emailTo =='')){$ emailTo =   the_author_meta(' USER_EMAIL&#39); } $ subject ='电子邮件主题去了   这里' $名称; $ body ="名称:$ Name nnDuration:$ duration nnComments:   $ comments&#34 ;;

     

$ headers ="回复:'"。$ name。"' RN&#34 ;;如果(wp_mail($ emailTo,   $ subject,$ body,$ headers)){

     回声"查询已成功发送&#34 ;;   } else {echo"邮件功能错误!&#34 ;; }

3 个答案:

答案 0 :(得分:1)

您可以通过 get_the_author_meta() wordpress函数获取作者电子邮件地址。

<?php 
      $user_email = get_the_author_meta('user_email');
?>

获取用户ID 25的电子邮件地址,并使用其显示名称作为锚文本进行回显。

<p>Email the author: 
     <a href="mailto: 
          <?php echo get_the_author_meta('user_email', 25); ?>"
     >
          <?php the_author_meta('display_name', 25); ?>
     </a>
</p>

以下功能 已弃用

 <?php the_author_email(); ?> 

Mailto Link

将作者电子邮件地址显示为&#34; mailto&#34;链接。

<a href="mailto:<?php the_author_email(); ?>">Contact the author</a>

演示代码

<div id="about-author-wrap">
     <div class="about-author-avatar">
        <?php echo get_avatar( get_the_author_email(), '90' ); ?>
     </div>
     <div class="about-author-info">                                
        <h5>About the Post Writer <small>View all posts by <?php the_author_posts_link(); ?></small></h5>
    </div>
    <div class="about-author-description">
        <?php the_author_meta("description"); ?>
    </div>
</div>

希望这对你有帮助!

答案 1 :(得分:0)

尝试以下代码。 Reference page。希望它有所帮助。

<?php $user_email = get_the_author_meta('user_email'); ?>

答案 2 :(得分:0)

尝试:

 $emailTo = '"'.the_author_meta('user_email').'"';