[_post_author_email] はループ内でのみ機能しますので author.php でユーザーの投稿が0件なら場合はこの方法は使えません。私ならこういう場合は特別なメールタグの機能をカスタムで拡張します。author.php 内なら get_query_var( ‘author’ ) でユーザーの ID がたぶん取れると思うので、includes/special-mail-tags.php を参考にそこから user_email を引き出すようなメールタグを作るというような方法が考えられます。プラグインのコードはいじらずテーマの functions.php 内で行うことをおすすめします。
返信有難うございます。
プログラムが得意ではないので敷居が高そうですが、色々と参考にしながら頑張ってみます。
提案いただいた方法ではわたしでは検討がつかなかったので、フォーラムにあった以下の方法で試しました。
http://wordpress.org/support/topic/contact-form-on-authorphp?replies=2
ユーザーの投稿が無ければカスタムポストのフェイクへ自動投稿するという方法だと思います。
バリデーションまではできるのですが、メッセージの送信が失敗したと出て送信できません。恐らくメールアドレスの受け渡しがうまくいってないのかなと思いますが悪い点などわかりますでしょうか?
表示するテンプレートはテーマ内の適当なファイルhogehoge.phpとします。
$user_data = get_userdata($author)
$cur_id = $user_data->ID;
$dis_name = $user_data->user_login;
$fakeposts = get_posts( array(
'post_type' => 'fake',
'author' => $cur_id )
);
if (!empty($fakeposts)) : // If there is a fakepost show the contact-form for it
foreach( $fakeposts as $post ) :
setup_postdata($post);
echo do_shortcode('[contact-form-7 id="100" title="ユーザー用問い合わせフォーム"]');
endforeach; wp_reset_postdata();
else:
$my_fakepost = array( // If there isn't a fakepost create one ...
'post_title' => 'fakepost_' . $dis_name,
'post_content' => '投稿が存在しません。' . $dis_name,
'post_status' => 'publish',
'post_author' => $cur_id,
'post_type' => 'fake'
);
$post_id = wp_insert_post( $my_fakepost );
$fakeposts = get_posts( array(
'p' => $post_id,
'post_type' => 'fake',
'author' => $cur_id )
);
foreach( $fakeposts as $post ) : // ... and show the contact form for it
setup_postdata($post);
echo do_shortcode('[contact-form-7 id="100" title="ユーザー用問い合わせフォーム"]');
endforeach; wp_reset_postdata();
endif;