Php 更改默认用户配置文件URL-BBpress插件
Bbpress Wordpress插件具有默认链接用户配置文件url。链接如下: 简而言之,主要目的是:我想更改url 事实上,我找到了解决办法,但并不完美。代码如下所示:Php 更改默认用户配置文件URL-BBpress插件,php,wordpress,bbpress,Php,Wordpress,Bbpress,Bbpress Wordpress插件具有默认链接用户配置文件url。链接如下: 简而言之,主要目的是:我想更改url 事实上,我找到了解决办法,但并不完美。代码如下所示: function user_profile_link(){ $url = 'http://localhost/example.com/profile/'; $author_id = bbp_get_reply_author_id(); $user_info = get_userdata($author
function user_profile_link(){
$url = 'http://localhost/example.com/profile/';
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
echo '<a href="'.$url.''.$user_info->user_login.'"> '. $user_info->display_name.' </a>';
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
<style>
.bbp-author-link{
display: none;
}
</style>
function user_profile_link(){
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
$url = site_url()."/profile/".$user_info->user_login;
return $url;
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
function user\u profile\u link(){
$url='1http://localhost/example.com/profile/';
$author\u id=bbp\u get\u reply\u author\u id();
$user\u info=get\u userdata($author\u id);
回声';
}
添加过滤器(“bbp\U获取用户配置文件\U url”,“用户配置文件\U链接”);
是的,代码运行良好。但结果是,用户配置文件URL没有被替换,并且有两个URL,如下图所示:
如果我显示:none it,我认为问题解决了。代码如下所示:
function user_profile_link(){
$url = 'http://localhost/example.com/profile/';
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
echo '<a href="'.$url.''.$user_info->user_login.'"> '. $user_info->display_name.' </a>';
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
<style>
.bbp-author-link{
display: none;
}
</style>
function user_profile_link(){
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
$url = site_url()."/profile/".$user_info->user_login;
return $url;
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
.bbp作者链接{
显示:无;
}
但有一个问题。我创建的新URL出现在面包屑旁边,如下图所示:
我想删除出现在面包屑旁边的链接。有什么解决办法吗?感谢您的帮助。谢谢在过滤器挂钩中,通常必须通过返回当前值来覆盖当前值。因此,请尝试使用已创建的函数返回新值。它可以删除副本 另外,请使用而不是
$url
变量,因为使用硬编码url时会出现问题
function user_profile_link(){
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
return site_url()."/profile/".$user_info->user_login;
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
在过滤器挂钩中,通常必须通过返回当前值来覆盖当前值。因此,请尝试使用已创建的函数返回新值。它可以删除副本 另外,请使用而不是
$url
变量,因为使用硬编码url时会出现问题
function user_profile_link(){
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
return site_url()."/profile/".$user_info->user_login;
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
对于这个问题,我找到了解决办法 代码如下所示:
function user_profile_link(){
$url = 'http://localhost/example.com/profile/';
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
echo '<a href="'.$url.''.$user_info->user_login.'"> '. $user_info->display_name.' </a>';
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
<style>
.bbp-author-link{
display: none;
}
</style>
function user_profile_link(){
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
$url = site_url()."/profile/".$user_info->user_login;
return $url;
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
对于这个问题,我找到了解决办法 代码如下所示:
function user_profile_link(){
$url = 'http://localhost/example.com/profile/';
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
echo '<a href="'.$url.''.$user_info->user_login.'"> '. $user_info->display_name.' </a>';
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
<style>
.bbp-author-link{
display: none;
}
</style>
function user_profile_link(){
$author_id = bbp_get_reply_author_id();
$user_info = get_userdata($author_id);
$url = site_url()."/profile/".$user_info->user_login;
return $url;
}
add_filter('bbp_get_user_profile_url', 'user_profile_link');
值得注意的是,如果您将
localhost
作为域名,这将始终尝试在运行浏览器的PC上查找url的其余部分!!!因此,它可能对您有效,但如果您让我使用该网站,它将不会像您认为的那样有效。请注意,如果您将localhost
作为域名,这将始终尝试在运行浏览器的PC上查找url的其余部分!!!所以它可能对你有用,但如果你让我使用这个网站,它就不会像你认为的那样有效。多亏了你的回答,我找到了解决办法。我是这样做的:函数user_profile_link(){$author_id=bbp_get_reply_author_id();$user_info=get_userdata($author_id);$url=site_url()。“/profile/”$user_info->user_login;返回$url;.add_过滤器('bbp_get_user_profile_url,'user_profile_link');问题解决了。多亏了你的回答,我找到了解决办法。我是这样做的:函数user_profile_link(){$author_id=bbp_get_reply_author_id();$user_info=get_userdata($author_id);$url=site_url()。“/profile/”$user_info->user_login;返回$url;.add_过滤器('bbp_get_user_profile_url,'user_profile_link');问题解决了。