how to get avatar on front end wordpress


Staff member
Hello users of stack over flow, I have a little Question,

I am trying to get avatar in upper end of my website, if user is logged in I want to show

avatar and name and link to profile,

if user is not logged in I want to show login and register buttons

I know little bit of php only , I will have to use if else statement but how to call wordpress logged in user function ,


(if you provide me with a sample code that will help a lot)

I tried something like this

 <ul class="nav-userbox nav pull-right">
if ( is_user_logged_in() ) {
  echo 'Welcome, registered user!';

 <li id="menuLogin" class="dropdown">
        <a class="user-buttons" title="Register" href="./register?to=">


        <a id="navLogin" class="dropdown-toggle user-buttons" data-toggle="dropdown" href="#">


        <div class="dropdown-menu login-form">
            <form id="loginform" method="post" action="./login?to=">
                <input id="user_login" type="text" placeholder="Email or Username" name="log"></input>
                <input id="user_pass" type="password" placeholder="Password" name="pwd"></input>
                <label class="checkbox inline">
                    <input id="rememberme" type="checkbox" value="forever" name="rememberme"></input>


    <input id="wp-submit" type="submit" value="Log In" name="wp-submit"></input>
    <input type="hidden" value="" name="redirect_to"></input>
    <input type="hidden" value="" name="instance"></input>
    <input type="hidden" value="login" name="action"></input>


            <div class="custom">
                <div id="fb-root" class=" fb_reset" style="display:inline;">
                    <div style="position: absolute; top: -10000px; height: 0px; width: 0px;"></div>
                    <div style="position: absolute; top: -10000px; height: 0px; width: 0px;"></div>

                            window.fbAsyncInit = function() {

                <div class="fb-login-button fb_iframe_widget" scope="email,user_about_me,user_location,user_website" size="medium" style="display:inline; vertical-align:middle;" login_text=" " fb-xfbml-state="rendered" fb-iframe-plugin-query="app_id=332446126861609&locale=en_US&login_text=%0A%20%20%20%…about_me%2Cuser_location%2Cuser_website&sdk=joey&size=medium">
                    <span style="vertical-align: bottom; width: 0px; height: 0px;">
                        <iframe class="" height="1000px" frameborder="0" width="1000px" scrolling="no" name="f27f166a4e97fde" allowtransparency="true" title="fb:login_button Facebook Social Plugin" style="border: medium none; visibility: visible; width: 0px; height: 0px;" src="…about_me%2Cuser_location%2Cuser_website&sdk=joey&size=medium"></iframe>



But I got erros , Please can someone tell me what I am doing wrong