How to Retrieve author/user details from Product ID in WordPress

How to Retrieve author/user details from Product ID in WordPress

This code is used to Retrieve author/user details from Product ID. and this code add your function.php file in WordPress.

<?php
add_filter( 'manage_posts_columns', 'revealid_add_id_column', 5 );
add_action( 'manage_posts_custom_column', 'revealid_id_column_content', 5, 2 );

function revealid_add_id_column( $columns ) {
   $columns['revealid_id'] = 'User Name';
   return $columns;
}

function revealid_id_column_content( $column, $id ) {
  if( 'revealid_id' == $column ) {
 $auth = get_post($id); // gets author from post
 $authid = $auth->post_author;
 echo $user_email = get_the_author_meta('display_name',$authid);
  }
}
?>

 

Learn Tutorials Point
We Well organized and easy-to-understand Interactive tutorials With lots of examples of how to use Tutorials WordPress, PHP, Bootstrap, Bootstrap 4, HTML, CSS, AJAX, jQuery, Woocommerce, Post, Database, Javascript, Theme, Responsive, Templates.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact us

Fill in the form below or give us a call and we'll contact you. We endeavour to answer all enquiries within 24 hours on business days.