您可以使用wp\\u login\\u表单,类似这样的
if ( ! is_user_logged_in() and <any-other-condition>){
$args = array(
\'echo\' => false,
\'redirect\' => esc_url($_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]),
\'label_username\' => __( \'Username\' ),
\'label_password\' => __( \'Password\' ),
\'label_remember\' => __( \'Remember Me\' ),
\'label_log_in\' => __( \'Log In\' ),
\'id_username\' => \'user_login\',
\'id_password\' => \'user_pass\',
\'id_remember\' => \'rememberme\',
\'id_submit\' => \'wp-submit\',
\'remember\' => true,
\'value_username\' => NULL,
\'value_remember\' => false
);
$loginform = wp_login_form( $args );
}
...continue and do whatever with $loginform