Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Registrations and Spam.


deadlyhifi
Participant

@tomdebruin

The updated plugin has been working ok except it has major flaws :)

1 – The user displayname is not being put into the database – therefore all new users appear as a blank when they post.

2 – registration error messages aren’t displayed. (e.g. Invalid email)

The fix was straightforward. The bb_new_user function needed updating as so:

if (!function_exists('bb_new_user')) :
function bb_new_user( $user_login, $user_email, $user_url, $user_status = 0 ) {
global $wp_users_object, $bbdb;

// is_email check + dns
if ( !$user_email = bb_verify_email( $user_email ) )
return new WP_Error( 'user_email', __( 'Invalid email address' ), $user_email );

if ( !$user_login = sanitize_user( $user_login, true ) )
return new WP_Error( 'user_login', __( 'Invalid username' ), $user_login );

// user_status = 1 means the user has not yet been verified
$user_status = is_numeric($user_status) ? (int) $user_status : 0;

$user_nicename = $_user_nicename = bb_user_nicename_sanitize( $user_login );
if ( strlen( $_user_nicename ) < 1 )
return new WP_Error( 'user_login', __( 'Invalid username' ), $user_login );

while ( is_numeric($user_nicename) || $existing_user = bb_get_user_by_nicename( $user_nicename ) )
$user_nicename = bb_slug_increment($_user_nicename, $existing_user->user_nicename, 50);

$user_url = bb_fix_link( $user_url );
$user_registered = bb_current_time('mysql');
$password = wp_generate_password();
$user_pass = wp_hash_password( $password );

$user = $wp_users_object->new_user( compact( 'user_login', 'user_email', 'user_url', 'user_nicename', 'user_status', 'user_pass' ) );

if ( is_wp_error($user) ) {
if ( 'user_nicename' == $user->get_error_code() )
return new WP_Error( 'user_login', $user->get_error_message() );
return $user;
}

$user_id = $bbdb->insert_id;
$options = bb_get_option('approve_user_registration_options');
bb_update_usermeta( $user_id, $bbdb->prefix . 'capabilities', array('waitingapproval' => true, 'member' => true) );
approve_user_registration_send_pass( $user_id, $password );

do_action('bb_new_user', $user['ID'], $user['plain_pass']);
return $user['ID'];
}
endif;

although I am using a fairly hacked together install with some bleeding edge stuff in there so you may need to experiment a little.

Skip to toolbar