简体   繁体   English

在WordPress网站上创建一个外部链接,将用户名作为查询字符串参数传递

[英]Create an external link on wordpress site passing the username as a querystring parameter

I am adding a quick link on my wordpress site but that link is a custom link that redirects with the current username thats logged in. So, the link would be something like " http://www.example.com?currentuser= {username}". 我在wordpress网站上添加了一个快速链接,但该链接是一个自定义链接,该链接使用登录的当前用户名进行重定向。因此,该链接将类似于“ http://www.example.com?currentuser= {username }”。 I want this {username} to come from the system but I am not able to find either the right token for it or not sure what I am doing is correct? 我希望这个{username}来自系统,但是我找不到正确的令牌,或者不确定我在做什么吗? I am trying to add a quick link -> custom link on my site but needs the current username to be able to pass to as my querystring parameter. 我试图在我的网站上添加快速链接->自定义链接,但需要当前的用户名才能作为我的querystring参数传递给我。 How should I go about accomplishing this on the wordpress site? 我应该如何在wordpress网站上完成此任务? 在此处输入图片说明

Try if following is useful. 尝试以下是否有用。

$current_user = wp_get_current_user();
$loggedinuser = $current_user->user_login;
$linkurl = get_site_url().'/?currentuser='.$loggedinuser;
$displaylink = '<a href="'.$linkurl.'">Click Here</a>';
echo($displaylink);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM