--- bbp-core-widgets.php	2012-03-24 05:26:06.047950000 +0200
+++ bbp-core-widgets_new.php	2012-03-24 05:20:05.993356100 +0200
@@ -12,6 +12,103 @@
 // Exit if accessed directly
 if ( !defined( 'ABSPATH' ) ) exit;
 
+
+/*---------------------------------------------------------------------------------*/
+/* Online Users Widget */
+/*---------------------------------------------------------------------------------*/
+
+
+class BBP_Online_Users_Widget extends WP_Widget {
+
+
+
+	function register_widget() {
+		register_widget('BBP_Online_Users_Widget');
+	}
+
+	
+	function BBP_Online_Users_Widget()
+	{
+		$widget_ops = apply_filters( 'bbp_online_users_widget_options', array(
+			'classname'   => 'bbp_online_users_widget',
+			'description' => __( 'The online users widget.', 'bbpress' )
+		) );
+
+		parent::WP_Widget( false, __( 'bbPress Online Users Widget', 'bbpress' ), $widget_ops );
+	}
+	
+	/** @see WP_Widget::widget */
+	function widget( $args, $instance ) {
+		global $current_user;
+		
+		extract( $args );
+		$time = $instance['time'];
+		
+		$title = apply_filters('widget_title', empty($instance['title']) ? __('BBP Online Users') : $instance['title'], $instance, $this->id_base);
+		echo $before_widget;
+		
+		if ( $title ) {
+			echo $before_title . $title . $after_title; 
+		}
+		
+		echo '<ul>';
+
+			if(is_user_logged_in()) {
+				update_user_meta( $current_user->ID, 'last_time', time() );
+			}
+
+			$wp_user_search = new WP_User_Query( array( 'meta_key' => 'last_time', 'meta_value' => time() - $time, 'meta_compare' => '>' ) );
+			$users = $wp_user_search->get_results();
+
+			if(!empty($users)) {
+				foreach($users as $user) {
+					$avatar = get_avatar( $user->ID, 14 );
+					echo '<span><a href="' . bbp_get_user_profile_url($user->ID) . '"> ' . $avatar . '</a>' . '<a href="' . bbp_get_user_profile_url($user->ID) . '"> ' . get_the_author_meta( 'user_login', $user->ID ). '</a></span>';
+				}
+			} else {
+				echo '<p>No online users found!</p>';
+			}
+			
+		echo '</ul>';
+		
+		echo $after_widget;
+	}
+
+	/** @see WP_Widget::update */
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$instance['title'] = strip_tags($new_instance['title']);
+		$instance['time'] = strip_tags($new_instance['time']);
+		return $instance;
+	}
+
+	/** @see WP_Widget::form */
+	function form( $instance ) {
+		if ( $instance ) {
+			$title = esc_attr( $instance[ 'title' ] );
+			$time = esc_attr( $instance[ 'time' ] );
+		}
+		else {
+			$title = __( 'Online Users', 'bbpress' );
+			$time = '180';
+		}
+		?>
+		<p>
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> 
+			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
+			<label for="<?php echo $this->get_field_id('time'); ?>"><?php _e('Time (in seconds):'); ?></label> 
+			<input class="widefat" id="<?php echo $this->get_field_id('time'); ?>" name="<?php echo $this->get_field_name('time'); ?>" type="text" value="<?php echo $time; ?>" />
+		</p>
+		<?php 
+	}
+	
+
+
+} 
+
+
+
+
 /**
  * bbPress Login Widget
  *
