admin管理员组文章数量:1312681
I've noticed that if "Website" is filled in on a user's Profile page, then the link formed around the username of that user will often (not always) point to that offsite link instead of to the onsite profile (or, rather, either of two onsite profiles, if you have BBPress).
It's very idiosyncratic. As a demo, see:
://cuindlis/2022/05/14/at-long-last/
- The first occurrence of my name, as author of the original post under the "Published 2022-5-14" line, links to my
/author/smccandlish/
profile (this would be better as/forums/users/smccandlish/
since I have BBPress installed and it provides better profiles; I guess I could force that with a redirect). - The 2nd linked occurrence of my name, atop my reply to another user's reply to my original post, goes to my LinkedIn profile, the URL given in "Website" on the profile form. That is completely undesirable.
- The 3rd linked occurrence of my name, in page-bottom site-wide navigation under "Recent Comments", also unacceptably points to LinkedIn. That LinkedIn URL should not be used for anything at all, ever, other than as an entry on the profile page.
- If you go to the Forums section (at that archive or at my live site), the usernames consistently link, as desired, to the
/forums/users/smccandlish/
profile (and similar for other users). These links seem to be forced on.
At first I thought that either of two simple-in-theory approaches might worK: One would be to disable whatever it is that's causing these offsite links, but leave the "Website" profile field alone otherwise. The other would be to disable that entire form field and let it default to an onsite profile link (one would hope), then add in a replacement form field that serves the same user-facing purpose of showing a URL on the profile page to other users, but is not something that is "magically" acted upon by anything as a source of URLs to inject into other pages as a username link.
However, if you look at the username of the user who replied to my original post there, you'll see that their username is not linked at all (because they didn't put anything in the "Website" form field?). While usernames are linked to profiles automatically in BBPress, for regular WP Comments (replies to Posts), this is not happening.
So, I'm not sure how to get consistent behavior of: all usernames being linked to profiles, regardless of form-field input; no such links ever being replaced by offsite URLs; and the profile URLs being the same in all cases (to the BBPress profiles).
PS: In case it matters for technical reasons, I'm using the theme "Twenty Twenty-One" as the basis for the site, though I've already customized this in various ways, so it's not really easily replaceable.
I've noticed that if "Website" is filled in on a user's Profile page, then the link formed around the username of that user will often (not always) point to that offsite link instead of to the onsite profile (or, rather, either of two onsite profiles, if you have BBPress).
It's very idiosyncratic. As a demo, see:
https://web.archive.org/web/20230908114450/https://cuindlis.org/2022/05/14/at-long-last/
- The first occurrence of my name, as author of the original post under the "Published 2022-5-14" line, links to my
/author/smccandlish/
profile (this would be better as/forums/users/smccandlish/
since I have BBPress installed and it provides better profiles; I guess I could force that with a redirect). - The 2nd linked occurrence of my name, atop my reply to another user's reply to my original post, goes to my LinkedIn profile, the URL given in "Website" on the profile form. That is completely undesirable.
- The 3rd linked occurrence of my name, in page-bottom site-wide navigation under "Recent Comments", also unacceptably points to LinkedIn. That LinkedIn URL should not be used for anything at all, ever, other than as an entry on the profile page.
- If you go to the Forums section (at that archive or at my live site), the usernames consistently link, as desired, to the
/forums/users/smccandlish/
profile (and similar for other users). These links seem to be forced on.
At first I thought that either of two simple-in-theory approaches might worK: One would be to disable whatever it is that's causing these offsite links, but leave the "Website" profile field alone otherwise. The other would be to disable that entire form field and let it default to an onsite profile link (one would hope), then add in a replacement form field that serves the same user-facing purpose of showing a URL on the profile page to other users, but is not something that is "magically" acted upon by anything as a source of URLs to inject into other pages as a username link.
However, if you look at the username of the user who replied to my original post there, you'll see that their username is not linked at all (because they didn't put anything in the "Website" form field?). While usernames are linked to profiles automatically in BBPress, for regular WP Comments (replies to Posts), this is not happening.
So, I'm not sure how to get consistent behavior of: all usernames being linked to profiles, regardless of form-field input; no such links ever being replaced by offsite URLs; and the profile URLs being the same in all cases (to the BBPress profiles).
PS: In case it matters for technical reasons, I'm using the theme "Twenty Twenty-One" as the basis for the site, though I've already customized this in various ways, so it's not really easily replaceable.
Share Improve this question asked Jun 24, 2024 at 3:58 S. McCandlishS. McCandlish 1032 bronze badges1 Answer
Reset to default 1Yup, there'll be no link when the user doesn't fill in that field or when leaving a comment as a guest.
As far as redirecting comment links to the bbPress profile goes, popping this in your functions.php should do the trick:
/**
* Redirect user links in comments to BBPress profile
*
* @param object $comment
* @return object
*/
function wpse425792_comment_author_url($comment) {
if ( $comment->user_id && function_exists( 'is_bbpress' ) ) {
$comment->comment_author_url = bbp_get_user_profile_url( $comment->user_id );
}
return $comment;
}
add_filter('get_comment', 'wpse425792_comment_author_url');
[Edited to add a missing ")" on the "if" line. This note added to get around the "Edits must be 6 characters" problem.]
本文标签:
版权声明:本文标题:users - Force Profile link for username, and stop "Website" field on Profile from becoming offsite link atop C 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302671a1931620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论