Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hey i installed buddypress and wanted to know if there is a theme function o can add so that on my theme it says

Login • Sign Up

and when they login it says

My Profile • Sign Out

share|improve this question

2 Answers 2

There isn't a specific function that will do this, but it's definitely something you can add to your site. Personally, I've added a custom widget to one of my sites that displays this kind of functionality in the upper-right corner.

Here is some of the code I use:

<?php
$current_user = wp_get_current_user();
$email_hash = md5( $current_user->user_email );
?>
<div class="login_widget">
    <?php if ( is_user_logged_in() ) { ?>
        <div class="actions">
            <ul>
                <li class="first-line">Welcome, <?php echo $current_user->display_name; ?>!</li>
                <li><a href="<?php echo admin_url( 'profile.php' ); ?>" title="Profile">Manage Your Profile</a></li>
                <li><a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Log Out</a></li>
            </ul>
        </div>
        <img src="http://www.gravatar.com/avatar/<?php echo $email_hash; ?>?s=50" alt="Gravatar" width="50" height="50" />
    <?php } else { ?>
        <div class="actions">
            <ul>
                <li class="first-line">
                    <a href="<?php echo wp_login_url( get_permalink() ); ?>">Log in</a> or
                    <a href="<?php echo site_url( 'register' ); ?>">join the community</a>
                </li>
            </ul>
        </div>
    <?php } ?>
</div>

If the user is logged in, it displays a box like this: Display when user is logged in

If the user is logged out, it displays a line of text like this: Display when user is logged out

share|improve this answer
    
Something is missing from the top line it doesn't begin with anything, i don't think that will work –  Terrell Anderson Mar 3 '12 at 1:08
    
The only thing that might be missing is an opening <?php tag (which I've now added). But this code will do exactly what I say it will - I copied it from a live site and used the life site to make the screenshots at the bottom of my answer. Have you at least attempted to implement this answer? –  EAMann Mar 3 '12 at 3:21
    
Thank you so much for this :) –  Terrell Anderson Mar 3 '12 at 10:27

A quick note that @EAMann's answer isn't BuddyPress-specific. If you want to point to the user's BP profile edit page instead of the WP Dashboard version, replace

admin_url( 'profile.php' )

with

bp_loggedin_user_domain()
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.