Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get Username ???

  • @trcwest

    Participant

    Hi there i have a button that creates a group or in my case a spot and i have been using this on my main blog theme..

    <?php echo wt_get_user_name(); ?>

    this it in full

    <?php if ( is_user_logged_in() ) : ?>

    <div id=”create-spot”>

    /spots/create/”>

    <img src=”http://spotskenya.com/images/add-spot-glow.png&#8221; alt=”creat spot” />

    </div>

    <?php else : ?>

    <?php endif; ?>

    BUT on the bp theme it doesnt work and it kills the whole theme..

    is there an alternative echo username php function to this… <?php echo wt_get_user_name(); ?>

Viewing 10 replies - 1 through 10 (of 10 total)
  • @burtadsit

    Participant

    Post the code for wt_get_user_name() here and leave a link http://buddypress.pastebin.com/

    @trcwest

    Participant

    This is what i have in my main blog theme that works nicely.. in the wordpress header..

    http://buddypress.pastebin.com/m63552cf1

    I just want to do the same thing on the buddy press side of things..

    the above code doesnt work on the buddy press side.

    I have been trying things like..

    <?php echo bp_the_site_member_name(); ?>

    The idea is to just alow for a quick create group button that takes dynamically adds the users username based on this url..

    http://spotskenya.com/spotters/!!!!!username!!!!!/spots/create/

    does that make sense??

    @trcwest

    Participant

    i realise i may have to define the user name and then echo it but i dont know how to do this..

    @belogical

    Participant

    global $current_user;

    $username = $current_user->user_login;

    http://spotskenya.com/spotters/&lt;?php echo $username; ?>/spots/create/’

    @trcwest

    Participant

    Thank you so so so so so much that worked nicely..

    Sorry to bring this topic back up, but I am having a similar problem.

    I want to add a “Create a Group” button on my Groups page, and to be honest, I’m confused why buddypress wouldn’t put one there to begin with.

    So the link I tried (from the code above) is :

    href=”members/<?php echo $current_user; ?>/cells/create/”>Create a Group

    But where do I put the :

    global $current_user;

    $username = $current_user->user_login;

    part of the code?

    @djpaul

    Keymaster

    Such a button has been added to the default 1.2 theme.

    Try this http://buddypress.pastebin.com/m6144dbb0

    Hmm, didn’t work, it just took me back to the homepage.

    Maybe I’m doing something wrong, I’ll have a look.

    @mike-greening

    Member

    I was able to get what I wanted by using the following code. It’s a link and not a button, but it also detects whether the user is logged in and displays a different message if they are not, so you can send them to the sign up page.

    <?php if ( !is_user_logged_in() ) : ?>

    <p>Don’t see a group you like? < href=”../register”>Login or Sign Up to create a new group.</p>

    <?php else : ?>

    <p>Don’t see a group that can help you? < href=”../members/<?php global $current_user; get_currentuserinfo(); echo $current_user->user_login; ?>/groups/create/step/group-details”>Create a new group.</p>

    <?php endif; ?>

    Apparently there’s a get_currentuserinfo() function somewhere that lets you grab info, just like in WordPress. Go figure.

    https://codex.wordpress.org/Function_Reference/wp_get_current_user

    (Note: I took the “a”s out of the code because this forum is making them into links and the backticks are inexplicably not working)

    @butterscotchproxy

    Participant

    Thanks for this, though I used bp_loggedinuser_link() instead.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Get Username ???’ is closed to new replies.
Skip to toolbar