我想把wordpress登录屏幕放在我的主页上。如果用户未登录,我希望他们必须在框中输入用户名和密码(或注册)。。如果他们已经登录,我希望他们被重定向到概览页面。
如果用户未登录,则一切正常,但如果用户登录,则重定向不起作用。。
有人能告诉我下面的php代码有什么问题吗。
/* add login shortcode */
add_action( \'init\', \'my_add_shortcodes\' );
function my_add_shortcodes() {
add_shortcode( \'my-login-form\', \'my_login_form_shortcode\' );
}
function my_login_form_shortcode( $attr ) {
if ( is_user_logged_in()) {
wp_redirect(\'http://michellemarcus.co.za/thinkingmachines/overview/\') ;
}
if ( ! is_user_logged_in() )
/* Set up some defaults. */
$defaults = array(
\'label_username\' => \'Username\',
\'label_password\' => \'Password\'
);
/* Merge the user input arguments with the defaults. */
$attr = shortcode_atts( $defaults, $attr );
/* Set \'echo\' to \'false\' because we want it to always return instead of print for shortcodes. */
$attr[\'echo\'] = false;
return wp_login_form( $attr );
}