The MU forums have moved to WordPress.org

photo near logged in (4 posts)

  1. fplus
    Member
    Posted 16 years ago #

    Hello!
    On my front page, I have this code to log in:

    <!-- If User Is Logged In Display This -->
    <?php if (is_user_logged_in()) { ?> 
    
    Bienvenue <strong><font size="2pt" color="#ff0000"><?php echo $user_identity ?></font></strong>!
    <form name="loginform" id="loginform" action="<?php echo wp_logout_url(); ?>" method="post">
     <?php wp_register(); ?>
    <input type="submit" name="wp-submit" id="wp-submit" value="Se déconnecter" />
    <input type="hidden" name="redirect_to" value="<?php bloginfo('url'); ?>" />
    </form>
    </p>
    <!-- If User Is NOT Logged In Display This -->
    <? } else { ?>
    <form name="loginform" id="loginform" action="<?php bloginfo('url'); ?>/wp-login.php" method="post">
    <label for="log">Pseudo</label> <input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" />
    <label for="pwd">Mot de Passe</label> <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" />
    <input type="submit" name="wp-submit" id="wp-submit" value="LOG IN" /> </p>
    <a href="wp-signup.php">Crée ton Blog !</a>
    
    <a href="<?php bloginfo('url'); ?>/wp-login.php?action=lostpassword">Mot de Passe perdu?</a>
    <input type="hidden" name="redirect_to" value="<?php bloginfo('url'); ?>" />
    <input type="hidden" name="testcookie" value="1" />
    </form> 
    
    <? } ?>

    Once logged, there is a message: welcome user
    I'd like to show the photo of the user but I don't win the code...
    I tried this:

    if ($use_grav) {
    					$grav_img = get_avatar( $thispost[0]->user_email , $grav_size );
    					$thisgravatar = '<a href="'.$blog_link.'">'.$grav_img.'</a>';
    				} else { $thisgravatar = ''; }

    but it don't show anythig..
    If you had an idea the way to do it?
    Thank you
    (sorry for my English, it's a long long time I didn't use it)

  2. AndrewGerssen
    Member
    Posted 16 years ago #

    The problem lies within the variable $thispost which isn't filled, because you are not looking at a post, but a admin page. So here is what you have to do:

    $user = get_currentuserinfo();
    
    if ($use_grav) {
      $grav_img = get_avatar( $user->user_email , $grav_size );
      $thisgravatar = '<a href="'.$blog_link.'">'.$grav_img.'</a>';
    } else {
      $thisgravatar = '';
    }

    I think that should fix it. Maybe there is a better way, by calling the global variable, but I don't know it right now.

  3. fplus
    Member
    Posted 16 years ago #

    well, I must be as competent as a old dog...
    here is what I did:
    in my function.php file:

    function logimg() {
    $user = get_currentuserinfo();
    
    if ($use_grav) {
      $grav_img = get_avatar( $user->user_email , $grav_size );
      $thisgravatar = '<a href="'.$blog_link.'">'.$grav_img.'</a>';
    } else {
      $thisgravatar = '';
    }
    }

    and in my home.php:

    <? logimg(); ?>

    Would I have misunderstood the way to do it?
    Thank you

  4. fplus
    Member
    Posted 16 years ago #

    that's ok.
    a wpmu admin gave the right code:
    <a href="<?php echo $tmp_user_url; ?>" title="Go to your blog homepage"><?php echo get_avatar($user_ID,'48',get_option('avatar_default')); ?></a>

    If that could help someone else...
    Thank you for your help and have a good day

About this Topic