最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Username Variable in custom links?

programmeradmin0浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

The 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

发布评论

评论列表(0)

  1. 暂无评论