change author email to custom field value
-
I used post by email, and when someone submits a posts via email, the admin gets assigned author. I set up a custom field for the user that sends the post to fill in their email address.
So i have the email, i just need to change the author to that email address.
I know its possible because i found another post on this forum with a solution for rewriting it in general
https://www.ads-software.com/support/topic/custom-fields-for-author-email?replies=2
but i need to change to code to fit my custom field (“mailauthor”) and the post title will always be different, as they can type that themselves when sending the post via email
$custom_mail = get_post_meta($post->ID, ‘custom_email’, true);
if ($custom_mail != ”) {
wp_mail( $custom_mail, __(‘Contact “‘, ‘appthemes’).$post->post_title.'”‘, $message, $headers, $attachments );
}I always found this code to rewrite the author name:
https://www.wprecipes.com/rewrite-author-name-with-custom-field
<?php $author = get_post_meta($post->ID, “guest-author”, true);
if ($author != “”) {
echo $author;
} else {
the_author();
} ?>So i guess i need to combine these codes somehow, but i am no php expert. Anyone with help or tips?
- The topic ‘change author email to custom field value’ is closed to new replies.