Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #601835

    hi. how can i add a login area inside the avia layout builder?

    #601934

    Hi corneliaboehm!

    Please add following code to Functions.php file in Appearance > Editor

    add_action( 'init', 'my_add_shortcodes' );
    
    function my_add_shortcodes() {
    
    	add_shortcode( 'my-login-form', 'my_login_form_shortcode' );
    }
    function my_login_form_shortcode() {
    
    	if ( is_user_logged_in() )
    		return '';
    
    	return wp_login_form( array( 'echo' => false ) );
    }

    then you can display your login form using this shortcode

    [my-login-form]

    Regards,
    Yigit

    #602436

    Thank you Yigit. i have added the code. But i cannot see the login :)

    #602681

    Hi!

    That is because you are already logged in :)
    It is visible to logged out users. Please see screenshot in private content field

    Cheers!
    Yigit

    #605388

    Great. Thank you.

    #605390

    Is there a way to show a “logout” button when im logged in already?

    #605538

    Hi!

    Please change the code in Functions.php file to following one

    add_action( 'init', 'my_add_shortcodes' );
    
    function my_add_shortcodes() {
    
    	add_shortcode( 'my-login-form', 'my_login_form_shortcode' );
    }
    function my_login_form_shortcode() {
    
    	if ( is_user_logged_in() )
    		return wp_logout_url();
    
    	return wp_login_form( array( 'echo' => false ) );
    }

    Best regards,
    Yigit

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.