对于初学者,可以挂接到密码表单中。然后您可以自定义它。类似于:
add_filter( \'the_password_form\', \'custom_password_form\' );
function custom_password_form() {
global $post;
$o = \'<form action="\' . esc_url( site_url( \'wp-login.php?action=postpass\', \'login_post\' ) ) . \'" method="post">
\' . __( "This post is password protected. To view it please enter your password below: or add custom message" ) . \'
<label for="Email">\' . __( "Email:" ) . \' </label><input name="Email" type="text" size="20" required />
<label for="password">\' . __( "Password:" ) . \' </label><input name="post_password" id="password" type="password" size="20" required/>
<input type="submit" name="Submit" value="\' . esc_attr__( "Submit" ) . \'" />
</form>
\';
return $o;
}
此表单将替换现有的受密码保护的表单,尽管我相信您可以添加if语句以供有条件使用。