Username Exposed
-
This question is for Security.
How can I display nickname only instead username in links?I found this functions.php:
add_filter( 'request', 'wpse5742_request' ); function wpse5742_request( $query_vars ) { if ( array_key_exists( 'author_name', $query_vars ) ) { global $wpdb; $author_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='nickname' AND meta_value = %s", $query_vars['author_name'] ) ); if ( $author_id ) { $query_vars['author'] = $author_id; unset( $query_vars['author_name'] ); } } return $query_vars; }add_filter( 'author_link', 'wpse5742_author_link', 10, 3 ); function wpse5742_author_link( $link, $author_id, $author_nicename ) { $author_nickname = get_user_meta( $author_id, 'nickname', true ); if ( $author_nickname ) { $link = str_replace( $author_nicename, $author_nickname, $link ); } return $link; }It works, but only with Blog Posts, not in:
Comments, meta, widgets, etc.
Neither for: buddypress (activity, groups, members, notifications, etc.) and bbpress forums.If you Right Click on Public Name you can see the Username in:
http://www.yoursite.com/author/username (in Comments)
http://www.yoursite.com/members/username
http://www.yoursite.com/forums/profile/usernameAlso, If you go to a Buddypress Profile, you can see, for example:
John Doe
@johnstack (username)==========================
The correct:
John Doe
@johndoe (nickname)http://www.yoursite.com/author/nickname
http://www.yoursite.com/members/nickname
http://www.yoursite.com/forums/profile/nicknamePlease, any solution for Forcing to Show the Nickname Only (based on your first name and last name) in Profile and all Links.
The topic ‘Username Exposed’ is closed to new replies.