I'm trying to use custom links in the php code to link to buddypress profile pages.
Basically, I need a way to create a username constant so I can make links like
domain/members/--username--/profile domain/members/--username--/settings domain/members/--username--/other
with --username-- being the constant which changes the currently logged in user who clicks the link?
I Am sure this could be done in functions.php with a rewrite code but not sure where to begin.
If anyone could help it would be majorly appreciated... This has been racking my brain for weeks. I have no problems implementing the code... Just no idea how to create it?
I'm trying to use custom links in the php code to link to buddypress profile pages.
Basically, I need a way to create a username constant so I can make links like
domain/members/--username--/profile domain/members/--username--/settings domain/members/--username--/other
with --username-- being the constant which changes the currently logged in user who clicks the link?
I Am sure this could be done in functions.php with a rewrite code but not sure where to begin.
If anyone could help it would be majorly appreciated... This has been racking my brain for weeks. I have no problems implementing the code... Just no idea how to create it?
Share Improve this question asked Jul 30, 2016 at 17:46 Crafty McCrafty Mc 311 silver badge4 bronze badges1 Answer
Reset to default 1The User data of the currently logged in user in WordPress can be retrieved via wpget_current_user()
So you should be able to do something like this in your theme or wherever.
$current_user = wp_get_current_user();
echo '<a href="http://example/members/' . $current_user->user_login . '/profile">Your profile</a>.';
And build your link that way.
HTH