Skip to:

Re: friends online widget plugin extension



@nicola: Thanks a bunch for looking at the code!!! And anyways for your work at!!!


below is the code, it doesn’t work. th error message is:

Warning: Invalid argument supplied for foreach() in ../mu-plugins/ng-who_is_online_2_friends_ver0001.php on line 17

i am getting the feeling the project is way over my head. because i have really no experience in coding my self or on my own. until now i only worked with the given code of word- and buddypress, without diving deeply into php-programing.

therefor i am not even sure if it’s the right way to begin. my thought process was that the friends widget i have is identifying friends by their id’s. so the thing to do is comparing these id’s to those of the users online.

maybe that thought apart is over simplified. otherwise it could just as well be the case that my understanding for php isn’t enough.

possibly the best idea would be to buy a book about php. ;-) learn more about it and then begin to build widgets. otherwise it might be not that complicated, if you have the skills.


function bp_friend_o_avatar_thumb_mini( $template = false ) {
global $bp, $current_blog;

$options = get_blog_option( $current_blog->blog_id, 'bp_friend_o_avatar_thumb_mini' );

$friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );

$users = BP_Core_User::get_online_users($options['max_members']);


<?php if ( $friend_ids ) { ?>

<?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?>
<?php foreach ( $friend_ids[$i] == $users->user_id as $friend_ids ) : ?>

<a>"><?php echo bp_core_get_avatar( $friend_ids[$i], 1,/** here you can change the thumbnailsize **/ 32, 32 ) ?></a>

<?php endforeach; ?>
<?php } ?>

<?php } else { ?>

<?php } ?>
<div class="clear"></div>


function ng_fs_o_usersidebar() {

echo '<link rel="stylesheet" type="text/css" href="' . get_settings('siteurl') . '/wp-content/mu-plugins/ng-fs-sb/fs.css" />';


<div id="widget">
<ul id="friend-list_sb" class="item-avatar">

<?php bp_friend_o_avatar_thumb_mini() ?>
<?php }

function Widget_ng_fs_o_usersidebar($args) {
global $bp;
echo $before_widget;
echo $before_title;?>
<?php bp_word_or_name( __( "Friends", 'buddypress' ), __( "Friends", 'buddypress' )/*__( "%s's Friends", 'buddypress' )*/ ) ?> (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <a>displayed_user->domain . $bp->friends->slug ?>"><?php _e('All', 'buddypress') ?> &raquo;</a>
<?php echo $after_title;
echo $after_widget;

function init_Sidebar_BP_ng_fs_o_sb()
register_sidebar_widget(__('ng_fs_sb'), 'Widget_ng_fs_o_usersidebar');

add_action("plugins_loaded", "init_Sidebar_BP_ng_fs_o_sb");


Skip to toolbar