• Resolved ND

    (@nigeltduke2)


    Hello ??

    is it possible to use the current logged in user’s avatar as the menu icon/image. Let’s say I wanted to do it for the right menu icon/image

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Rui Guerreiro

    (@takanakui)

    Hi,

    Find this code in class-wp-mobile-menu-core.php located at mobile-menu/includes/

    
    if ( ! $titan->getOption( 'right_menu_icon_opt' ) || '' === $right_icon_image ) {
        $output .= '<i class="mob-icon-' . $titan->getOption( 'right_menu_icon_font' ) . ' mob-menu-icon"></i><i class="mob-icon-cancel mob-cancel-button"></i>';
    } else {					$output .= '<img src="' . 
        $right_icon_image . '" alt="' . __( 'Right Menu Icon', 'mob-menu-lang' ) . '">';
    }

    and replace it by this one

    $user_avatar = '';
    
    if ( is_user_logged_in() ) {
       $current_user = wp_get_current_user();
       $user_avatar = get_avatar( $current_user->user_email, 32 );
    }
    
     $output .= $user_avatar;
    

    Let me know if it worked.

    Thread Starter ND

    (@nigeltduke2)

    WOW IT WORKED!!! GENIUS!

    THANK YOU!!!

    • This reply was modified 7 years, 3 months ago by ND.
    Thread Starter ND

    (@nigeltduke2)

    one more question regarding this. So if the user is logged out, I see no icon or image shows for the right menu which is what I expected. But Is there a statement that can be inserted to show the regular right menu icon if the user is NOT logged in?

    Plugin Author Rui Guerreiro

    (@takanakui)

    Great.

    Replace this current code:

    $user_avatar = '';
    
    if ( is_user_logged_in() ) {
       $current_user = wp_get_current_user();
       $user_avatar = get_avatar( $current_user->user_email, 32 );
    }
    
     $output .= $user_avatar;

    by this one

    $user_avatar = '';
    
    if ( is_user_logged_in() ) {
       $current_user = wp_get_current_user();
       $user_avatar = get_avatar( $current_user->user_email, 32 );
       $output .= $user_avatar;
    } else {
         if ( ! $titan->getOption( 'right_menu_icon_opt' ) || '' === $right_icon_image ) {
             $output .= '<i class="mob-icon-' . $titan->getOption( 'right_menu_icon_font' ) . ' mob-menu-icon"></i><i class="mob-icon-cancel mob-cancel-button"></i>';
         } else {					$output .= '<img src="' . 
             $right_icon_image . '" alt="' . __( 'Right Menu Icon', 'mob-menu-lang' ) . '">';
         }
    }

    Can you send me your site url? I would love to have a look.

    If you want to keep the url private send me an email to [support AT wpmobilemenu DOT com]

    Thread Starter ND

    (@nigeltduke2)

    Sure ?? the site is https://www.truetalenttv.com

    Thread Starter ND

    (@nigeltduke2)

    BTW that last code worked like a charm too!

    Plugin Author Rui Guerreiro

    (@takanakui)

    cool. Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘User Avatar as Menu Icon?’ is closed to new replies.