Enter your keyword

Blog

How to add dynamic Author Emails in Contact Form 7

function author_email($tag)  {
$curauth = ( get_query_var( 'author_name' ) ) ? get_user_by( 'slug', get_query_var( 'author_name' ) ) : get_userdata( get_query_var( 'author' ) );
  $view = get_query_var( 'view' );
  $role = '';
  if ( in_array( 'author_role', $curauth->roles ) ) {
    $role = 'author_role';
  }
  $html = $curauth->user_email;
  return $html;
}
add_shortcode('authormail', 'author_email');

Use this Short Code in Contact form 7 => [dynamichidden email-author "authormail"] and use the contact Email shortcode  [email-author]

No Comments

Add your review

Your email address will not be published.

* Feilds are Required.