简体   繁体   English

如何在qoutes中获取wordpress发布作者的电子邮件

[英]How to get wordpress post author email in qoutes

I am trying to get wordpress post author email in a quote like "myeamil@live.com" on single.php page. 我试图在single.php页面上以诸如“ myeamil@live.com”的报价获取wordpress帖子作者的电子邮件。

Actually I wanna send email to that author who posted this post. 实际上,我想发送电子邮件给发布此帖子的那个作者。

I am using wp_mail function to send email to author from single.php page. 我正在使用wp_mail函数从single.php页面发送电子邮件给作者。

Here is the variable i am using but it is getting admin email. 这是我正在使用的变量,但它正在获取管理员电子邮件。

$emailTo = get_option('admin_email');

Instead of admin email I want author email who posted the post. 而不是管理员电子邮件,我需要发布该帖子的作者电子邮件。 I need help please. 我需要帮助。 Many thanks. 非常感谢。

Update 更新

Here is my code i am trying to do 这是我正在尝试做的代码

if(!isset($hasError)) { //$emailTo = "w_chand@live.com"; if(!isset($ hasError)){// $ emailTo =“ w_chand@live.com”; if (!isset($emailTo) || ($emailTo == '') ){ $emailTo = the_author_meta('user_email'); if(!isset($ emailTo)||($ emailTo =='')){$ emailTo = the_author_meta('user_email'); } $subject = 'email subject goes here'.$name; } $ subject ='电子邮件主题到这里'。 $body = " Name: $Name nnDuration: $duration nnComments: $comments "; $ body =“名称:$ Name nnDuration:$ duration nnComments:$ comments”;

$headers = "Reply-To: '".$name."' rn"; $ headers =“ Reply-To:'”。$ name。“'rn”; if(wp_mail($emailTo, $subject, $body, $headers)){ if(wp_mail($ emailTo,$ subject,$ body,$ headers)){

echo "Enquiry has been sent successfully"; 回显“查询已成功发送”; } else { echo "Mail function Error!"; } else {echo“邮件功能错误!”; } }

You can get by get_the_author_meta() wordpress function to get author email address. 您可以通过get_the_author_meta() wordpress函数获取作者电子邮件地址。

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

Get the email address for user ID 25, and echo it using their display name as the anchor text. 获取用户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>

Following function is deprecated , 不推荐使用以下功能,

 <?php the_author_email(); ?> 

Mailto Link Mailto链接

Displays author email address as a "mailto" link. 将作者的电子邮件地址显示为“ mailto”链接。

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

Demo Code 示范代码

<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>

Hope this help you! 希望这对您有所帮助!

Try below code. 尝试下面的代码。 Reference page . 参考页 Hope it helps. 希望能帮助到你。

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

尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM