Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Why is integration so troublesome?


_ck_
Participant

@_ck_

This plugin is meant as a temporarily workaround until the bug can be fixed in WordPress – it will replace “anonymous” with the user login.

Install it 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)

Skip to toolbar