Skip to:
Content
Pages
Categories
Search
Top
Bottom

Register / Login or Username


  • Sascha.H
    Participant

    @saschah-1

    Hey guys i installed bbpress now and want to display something in the header of my page. If the user isnt logged in i want to display “Register | Login”. If he is there should just displayed: “Hello, Username”. Does someone hava a solution? I think my php skills are enough for this but i dont know the variables or functions. I watched in the documentation but there a just a few functions displayed? Or did i watched on a false page?

Viewing 2 replies - 1 through 2 (of 2 total)

  • Sascha.H
    Participant

    @saschah-1

    Well this is now my solution. Seems ok

    <?php
    if ( ! is_user_logged_in() ) {
        wp_nav_menu( array( 'theme_location' => 'Register or Login' ) ); 
    }  
    else {
        global $current_user;
        get_currentuserinfo();
        $current_user->user_login;
    				
        echo "Logged in as: ";?>                
        <a href="<?php echo get_edit_user_link(); ?>">
            <?php echo $current_user->user_login; ?>
        </a>				
    <?php }	?> 

    tharsheblows
    Participant

    @tharsheblows

    Oh good – I have this in a header – it’s about the same but $user_identity is the display name rather than the login. This explains the different global variables from get_currentuserinfo() – https://codex.wordpress.org/Function_Reference/get_currentuserinfo . Just in case you want the full reference – I hadn’t really looked at it before and noticed we used different variables and wondered why and thought you might be interested too. 🙂

    <?php if ( is_user_logged_in() ) { ?>
      <span class="break-me">
      Welcome, 
      <?php 
    	global $user_identity;
    	get_currentuserinfo();
    	printf('%s', $user_identity); ?>! 
      </span>
      <span class="break-me">
    	<a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Log out?</a> &bull; <a href="<?php echo bbp_get_user_profile_url(get_current_user_id()); ?>" name="Your profile and posts">Your profile</a> 
      </span>
    <?php } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar