Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Get Username ???


mike-greening
Member

@mike-greening

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)

Skip to toolbar