WordPress.org

Forums

Customizr
[resolved] Login Form (9 posts)

  1. Obliteran
    Member
    Posted 1 year ago #

    Hi,
    how to add the login button in the header and change the login form?

  2. d4z_c0nf
    Member
    Posted 1 year ago #

    In the header where?
    http://www.themesandco.com/snippet/adding-a-facebook-like-button-in-the-header/
    http://www.themesandco.com/snippet/adding-custom-social-profile-link-icon-header/
    for the last link, look for Nicolas answer:

    Hi Fadi, you can use the hooks provided in the snippet and add the wp_login_form() function to one of them.
    More about wp_login_form() : http://codex.wordpress.org/Function_Reference/wp_login_form

    Hope this helps

    About the login form, is a wordpress "issue", you can find a lot of good way to achieve that just googling for "customize worpdress login form".

  3. Obliteran
    Member
    Posted 1 year ago #

    on right,like themesandco.com; there is anywhere the code for this?
    http://www.themesandco.com/account/

  4. d4z_c0nf
    Member
    Posted 1 year ago #

  5. Obliteran
    Member
    Posted 1 year ago #

    i copy it in functions.php of my child-theme but they don't work...:(

    <?php
    //Add login/logout link to naviagation menu
    function add_login_out_item_to_menu( $items, $args ){
    
    	//change theme location with your them location name
    	if( is_admin() ||  $args->theme_location != 'primary' )
    		return $items; 
    
    	$redirect = ( is_home() ) ? false : get_permalink();
    	if( is_user_logged_in( ) )
    		$link = '<a href="' . wp_logout_url( $redirect ) . '" title="' .  __( 'Logout' ) .'">' . __( 'Logout' ) . '</a>';
    	else  $link = '<a href="' . wp_login_url( $redirect  ) . '" title="' .  __( 'Login' ) .'">' . __( 'Login' ) . '</a>';
    
    	return $items.= '<li id="log-in-out-link" class="menu-item menu-type-link">'. $link . '</li>';
    }add_filter( 'wp_nav_menu_items', 'add_login_out_item_to_menu', 50, 2 );
    ?>

    i've already changed the name of the primary menu in "primary" but nothing....

  6. Obliteran
    Member
    Posted 1 year ago #

    i've find this code and it work; i don't know why but it work! XD

    function add_login_logout_link($items, $args)
    {
    if(is_user_logged_in())
    {
    $newitems = '<li><a title="Logout" href="'. wp_logout_url('index.php') .'">Logout</a></li>';
    $items .= $newitems;
    }
    else
    {
    $newitems = '<li><a title="Login" href="'. wp_login_url('index.php') .'">Login</a></li>';
    $items .= $newitems;
    }
    return $items;
    }
    add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
  7. d4z_c0nf
    Member
    Posted 1 year ago #

    Use this:

    //change theme location with your them location name
    	if( current_user_can('create_users') ||  $args->theme_location != 'main' )
    		return $items;

    instead of:

    //change theme location with your them location name
    	if( is_admin() ||  $args->theme_location != 'primary' )
    		return $items;

    is_admin() is used not correctly. And the theme location for customizr main menu is "main".
    Anyway that if statement will not show you the "login/logout" link if you're logged in as administrator. So if you don't want this "feature" then remove that block.

    Hope this helps.

  8. d4z_c0nf
    Member
    Posted 1 year ago #

    Don't know why? 'Cause it basically do the same thing but with different controls.
    Glad you solved.
    Would you mind marking this topic as solved?
    Thank you.

  9. Obliteran
    Member
    Posted 1 year ago #

    oh thank you very much!

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic