Tagged: , ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #279073

    Hey Guys!

    First of all you guys have done an awesome job. Congrats! This theme is simply amazing.
    I have a simple problem and would appreciate a quick repy on that.

    I want to place a “Login” button on the Navigation menu with an icon. It would be nice if the color of the button is yellow, same as in my logo. Please check the beta website for the color.

    The icon simply would look like this in the given exapmle website with a yellow background.

    The second thing I am looking for is that a function which replaces “Login” button with a “Logout” button when the user logged in.
    How can I do that without using a plugin ?

    Or is it simply possible to assign a button with an icon to a menu item without using any codes ?

    Thanks in advance

    #279198

    Hi geanguru!

    Thank you for using the theme.

    You can add something like this on functions.php:

    add_filter( 'wp_nav_menu_items', 'avf_add_login_item', 10, 2 );
    function avf_add_login_item ( $items, $args ) {
    	$loginout = wp_loginout('', false);
        if ($args->theme_location == 'avia') {
    		$items .= "<li class='login_link $sub2'>".$loginout."</li>";
    	 }
         return $items;
    }

    Use the .login_link css selector to modify the look of the loginout menu item.

    Regards,
    Ismael

    #279262

    Hi Ismael,

    Thank you for your quick response.

    To be honest I decided to show a completely different menu when the user is logged in. So instead of replacing “Login” button with “Logout” button I want to replace whole menu with a second custom menu.

    To do that I used below mentioned function

    function my_wp_nav_menu_args( $args = '' ) {
    
     if( is_user_logged_in() ) {
      $args['menu'] = 'logged-in';
    } else {
      $args['menu'] = 'logged-out';
    }
     return $args;
    }
    add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' ); 

    Where “logged-in” and “logged-out” represents two different custom menus I have created.

    But the problem with this function is that it changes the footer menu as well.

    How can I modify the function to make it replace the menu only in header ?

    Thank you very much in advance

    #279331

    Hi!

    Thank you for the info.

    Did you create two menus called logged-in and logged-out? If I am not mistaken, the code that you posted should call the logged-in menu when the user is logged in and the menu called logged-out when the user is not logged in. If you created those two menus, please try to use this:

    function my_wp_nav_menu_args( $args = '' ) {
     if( is_user_logged_in() && $args['theme_location'] == 'avia' ) {
      $args['menu'] = 'logged-in';
    } else {
      $args['menu'] = 'logged-out';
     }
     return $args;
     }
    add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' ); 

    Best regards,
    Ismael

    #279343

    Hey Ismael,

    Thanks a lot for your immediate response.

    Yes I have already created two custom menus. As described above “logged-in” menu when the user logged in and “logged-out” menu when the user logged out.

    The function you provided works fine but it still hasnt solved my problem yet.
    The main problem with above mentioned code is that it changes the menu in footer area as well.

    Please see the regarding website here http://www.geanguru.com

    I guess there should be some “else” command for the footer menu so called “secondary” or whatsoever. Dont you think ?
    I couldnt solve the problem on my own so your help is highly appreciated.

    Thanks in advance

    • This reply was modified 10 years, 6 months ago by geanguru.
    #280987

    Hey!

    Thank you for the update.

    Please add the footer menu again. If possible, please post the login details here. We would like to inspect it.

    Best regards,
    Ismael

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