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 ); $bbdb->insert( $bbdb->users, compact( 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered' ) ); $user_id = $bbdb->insert_id; $options = bb_get_option('approve_user_registration_options'); if ( defined( 'BB_INSTALLING' ) ) { bb_update_usermeta( $user_id, $bbdb->prefix . 'capabilities', array('keymaster' => true) ); } else { 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, $password); return $user_id; } endif; if (!function_exists('bb_check_login')) : function bb_check_login($user, $pass, $already_md5 = false) { global $bbdb; $user = sanitize_user( $user ); if ($user == '') { return false; } $user = bb_get_user_by_name( $user ); $test_user = new BB_User($user->ID); if ($test_user->has_cap('waitingapproval')) return false; if ( !wp_check_password($pass, $user->user_pass, $user->ID) ) { return false; } return $user; } endif; function approve_user_registration_send_pass( $user, $pass ) { if ( !$user = bb_get_user( $user ) ) return false; $options = bb_get_option('approve_user_registration_options'); $passtext = ($options['send_password_with'] != 'A') ? sprintf("\nYour password is: %1\$s ",$pass) : ''; $message = __("Your username is: %1\$s $passtext\nYour registration is being held for approval by the administrator. Once it is approved you can log on here: %2\$s \n\nEnjoy!"); return bb_mail( bb_get_user_email( $user->ID ), bb_get_option('name') . ': ' . __('User Registration'), sprintf( $message, $user->user_login, bb_get_option('uri') ) ); } if (!BB_IS_ADMIN) { return; } add_action( 'bb_admin_menu_generator', 'approve_user_registration_add_admin_page' ); function approve_user_registration_add_admin_page() { bb_admin_add_submenu(__('Registration Queue'), 'moderate', 'approve_user_registration_admin_page', 'users.php'); bb_admin_add_submenu(__('Registration Settings'), 'moderate', 'approve_user_registration_settings_page', 'options-general.php'); } function approve_user_registration_settings_page() { $options = bb_get_option('approve_user_registration_options'); ?>

Registration Settings

Registration Mail type="radio" name="approve_user_registration[send_password_with]" id="send_password_with_registration" value="R"/> Approval Mail type="radio" name="approve_user_registration[send_password_with]" id="send_password_with_approval" value="A"/>

role = 'waitingapproval'; $this->raw_page = ( '' == $page ) ? false : (int) $page; $this->page = (int) ( '' == $page ) ? 1 : $page; $this->prepare_query(); $this->query(); $this->do_paging(); } function display( $show_search = true, $show_email = false ) { global $bb_roles; $r = ''; // Make the user objects foreach ( $this->get_results() as $user_id ) { $tmp_user = new BB_User($user_id); $roles = $tmp_user->roles; $role = array_shift($roles); $roleclasses[$role][$tmp_user->data->user_login] = $tmp_user; } if ( isset($this->title) ) $title = $this->title; elseif ( $this->is_search() ) $title = sprintf(__('Users Matching "%s" by Role'), wp_specialchars( $this->search_term )); else $title = __('User List by Role'); $r .= "

$title

\n"; if ( $show_search ) { $r .= "\n\n"; } if ( $this->get_results() ) { if ( $this->is_search() ) $r .= "

\n\t" . __('« Back to All Users') . "\n

\n\n"; $r .= '

' . sprintf(__('%1$s – %2$s of %3$s shown below'), $this->first_user + 1, min($this->first_user + $this->users_per_page, $this->total_users_for_query), $this->total_users_for_query) . "

\n"; if ( $this->results_are_paged() ) $r .= "
\n" . $this->paging_text . "
\n\n"; foreach($roleclasses as $role => $roleclass) { ksort($roleclass); if ( !empty($role) ) $r .= "

{$bb_roles->role_names[$role]}

\n"; else $r .= "

" . __('Users with no role in these forums') . "

\n"; $r .= "\n"; $r .= "\n"; $r .= "\t\n"; $r .= "\t\t\n"; if ( $show_email ) { $r .= "\t\t\n"; $r .= "\t\t\n"; } else { $r .= "\t\t\n"; } $r .= "\t\t\n"; $r .= "\t\n"; $r .= "\n\n"; $r .= "\n"; foreach ( (array) $roleclass as $user_object ) { //$r .= bb_user_row($user_object->ID, $role, $show_email); $user = bb_get_user( $user_object->ID ); $r .= "\t\n"; $r .= "\t\t\n"; $r .= "\t\t\n"; if ( $show_email ) { $email = bb_get_user_email( $user->ID ); $r .= "\t\t\n"; } $r .= "\t\t\n"; $r .= "\n\t"; } $r .= "\n"; $r .= "
" . __('ID') . "" . __('Username') . "" . __('Email') . "" . __('Username') . "" . __('Registered At') . "
" . get_user_name( $user->ID ) . "$email" . date( 'Y-m-d H:i:s', bb_offset_time( bb_gmtstrtotime( $user->user_registered ) ) ) . "
\n\n"; } if ( $this->results_are_paged() ) $r .= "
\n" . $this->paging_text . "
\n\n"; } ?>

title = __('These users are waiting for their account to be approved'); $bb_waiting_users->display( false, bb_current_user_can( 'edit_users' ) ); } function approve_user_registration_approve_user($user_id) { global $bbdb; $user = new BB_User($user_id); $user->remove_cap('waitingapproval'); $options = bb_get_option('approve_user_registration_options'); $user = bb_get_user($user_id); $password = wp_generate_password(); $user_pass = wp_hash_password( $password ); $bbdb->update( $bbdb->users, compact( 'user_pass'), array('ID' => $user->ID) ); $passtext = ($options['send_password_with'] == 'A') ? sprintf("\nYour password is: %1\$s ",$password) : ''; $message = __("Your user %1\$s has been approved by the administrator. $passtext\nYou can now log on: %2\$s \n\nEnjoy!"); return bb_mail( bb_get_user_email( $user->ID ), bb_get_option('name') . ': ' . __('User Approved'), sprintf( $message, $user->user_login, bb_get_option('uri') ) ); } function approve_user_registration_reject_user($user_id) { global $bbdb; $user = new BB_User($user_id); $user->remove_cap('waitingapproval'); $user->remove_cap('member'); $user->add_cap('blocked'); $user = bb_get_user($user_id); $message = __("Your user %1\$s has been rejected by the administrator."); return bb_mail( bb_get_user_email( $user->ID ), bb_get_option('name') . ': ' . __('User Rejected'), sprintf( $message, $user->user_login ) ); } add_action('bb_admin-footer.php','approve_user_registration_dashboard'); function approve_user_registration_dashboard() { global $page,$bb_current_menu; $waiting_user = new BB_Users_By_Role( 'waitingapproval' ); if($bb_current_menu[0] == 'Dashboard' && $waiting_user->total_users_for_query > 0 ) : ?>