#922 closed defect (worksforme)
bbPress is not inserting display names during registration
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | highest | Milestone: | 1.0 |
| Component: | Integration | Version: | 0.9.0.2 |
| Severity: | critical | Keywords: | |
| Cc: |
Description
I thought this was fixed for 0.9.0.2 but apparently not.
When integrated, bbPress fails to insert a display name so WordPress shows the user as "anonymous" even though they have an ID and a user_login (this could be considered WordPress bug too but bbPress made the problem, it should fix it...)
Perhaps there should also be a check on upgrade/reinstall to scan the user table for users without display names and create them to fix forums with this problem extensively.
props ragekage: http://bbpress.org/forums/topic/why-is-integration-so-troublesom#post-17389
pluggable.php in bb-includes Line 502 $bbdb->insert( $bbdb->users,compact( 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered' )); Replace with // bbPress / Wordpress bug fix added display name to wordpress $display_name = $user_login; $bbdb->insert( $bbdb->users,compact( 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'display_name' ));
Change History (7)
Mini-plugin to repair user table by copying user_login to display_name if display_name is blank:
function fix_anonymous() {global $bbdb;
$bbdb->query("UPDATE $bbdb->users SET display_name=user_login WHERE display_name='' ");
} add_action('bb_init','fix_anonymous');
However this is a horrendous waste of database space.
It's indeed a bug on the WordPress side that when the display_name is empty to display "anonymous" regardless if there is a valid user id # and user_login. It's meant to deal with anonymous commenters that have no account but it fails to anticipate a registered user with no display name.
I am also filing a WordPress ticket on this.
I've now posted a corresponding WordPress Trac ticket with fix:
This plugin is meant as a temporarily workaround - it will replace "anonymous" with the user login. It is meant to be installed on the WordPress side:
<?php
/*
Plugin Name: changes anonymous to member's login if display name missing (plugin for WordPress)
*/
function no_anonymous_members($author) { // this is a WORDPRESS plugin, not bbPress
global $comment;
if (empty($comment->comment_author) && !empty($comment->user_id)) {$user=get_userdata($comment->user_id); $author=$user->user_login;}
return $author;
} add_filter('get_comment_author', 'no_anonymous_members');
if ( !function_exists('get_userdata') ) :
function get_userdata( $user_id ) {
global $wpdb;
$user_id = absint($user_id);
if ( $user_id == 0 )
return false;
$user = wp_cache_get($user_id, 'users');
if ( $user )
if (empty($user->display_name)) {$user->display_name=$user->user_login;}
return $user;
if ( !$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id)) )
return false;
_fill_user($user);
if (empty($user->display_name)) {$user->display_name=$user->user_login;}
return $user;
}
endif;
?>
The real answer of course is to insert the user_login when the comment is posted however I cannot find a suitable hook in WordPress's comment-template.php so I am doing it by completely replacing the get_userdata function in pluggable.php
- Resolution set to worksforme
- Status changed from new to closed
Replying to _ck_:
The problem persists in 1.0 alpha and is on line 487
This is not a problem in trunk. $wp_users_object->new_user() handles this.
The problem persists in 1.0 alpha and is on line 487