简体   繁体   English

Woocommerce-获取产品作者的电子邮件地址

[英]Woocommerce - get product author's email address

I am struggling to find out how to fetch the product author's email address from Woocommerce. 我正在努力寻找如何从Woocommerce获取产品作者的电子邮件地址。

I'm trying this: 我正在尝试:

<?php
global $post, $product;
$author_email = get_the_author_meta( 'email', $product->post->post_author );
return $author_email;
?>

But that doesn't seem to be correct 但这似乎并不正确

The correct meta is user_email not email 正确的meta是user_email而不是email

<?php
global $post, $product;
$author_email = get_the_author_meta( 'user_email', $product->post->post_author );
return $author_email;
?>

Link to function description 链接到功能说明

Check that function, paste it on function.php 检查该功能,将其粘贴在function.php上

add_filter('post_type_link', 'add_author_id', 10, 4);

function add_author_id($post_link, $post, $leavename, $sample) {
if ('product' != get_post_type($post))
    return $post_link;
$authordata = get_userdata($post->post_author);
$author = $authordata->id;
$post_link = str_replace('%author%', $author, $post_link);
return $post_link;
 }

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

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