I have created a custom post type & have enabled frontend posting for the same. I need the Edit post page to display the original author's email id. I already have "post author" displayed, but that just gives the name & username of the author. How do I go about doing this?


Probably you use get_post on edit page with query object. You can simply use $post->post_author on edit page. For example;

$editableid = get_query_var('id');
$postedit = get_post($editableid);
$author_id = $postedit->post_author; //Always return author ID value.

<input type="hidden" name="post_author" value="<?php echo $author_id;?>" />

I hope this code piece helps you.

EDIT : For email you use the_author_meta with your $author_id value.

  • Thanks but I found another way around. Marked this as a solution for anyone looking to do the same – Sumit Shetty Aug 22 '18 at 5:44
  • I had a form on the frontend from which a user can submit the post data. I needed that author's email id to show up in the post that he created. So what I did was to add a hidden field in the form & called the user's email id into another field using a shortcode. Then on selection of a dropdown, I put in a jquery where the hidden field would be filled automatically. Sounds complicated, but worked out. – Sumit Shetty Aug 22 '18 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.