Joe Bloggs
Joe Bloggs

Reputation: 1462

Woocommerce - get product author's email address

I am struggling to find out how to fetch the product author's email address from 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

Upvotes: 2

Views: 5060

Answers (2)

Jasbir
Jasbir

Reputation: 376

Check that function, paste it on 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;
 }

Upvotes: 0

Core972
Core972

Reputation: 4114

The correct meta is user_email not email

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

Link to function description

Upvotes: 5

Related Questions