Skip to:
Content
Pages
Categories
Search
Top
Bottom

friends online widget plugin extension

  • @ngsonst

    Participant

    hi,

    i am desperately searching for a solution how to make a “friends online widget”. it seems to be the case that my knowledge isn’t enough for that. i tried to do it with the build in bp functions, but no success. on the following topic is a suggestion from fishbowl81:

    http://buddypress.org/forums/topic.php?id=1372

    my problem is that i don’t understand enough sql to have a break through. maybe it isn’t that complicated and some can help me. i would appreciate that very much! thanks in advance!

Viewing 8 replies - 1 through 8 (of 8 total)
  • @nicolagreco

    Participant

    You don’t need sql,

    use bp classes:

    look the default one and add on it that

    if (check if the user_id is friend) show

    i’ll look the code soon

    @ngsonst

    Participant

    thanks! now i know i don’t need to work with sql. i thought and tried it with the bp classes like you say, but i had no success. now i will try again! hopefully soon i post an upadte.

    @nicolagreco

    Participant

    post here the code, if it works or not..

    i don’t have time to write it for you, but i can say where you’re wrong :D

    @ngsonst

    Participant

    @nicola: Thanks a bunch for looking at the code!!! And anyways for your work at bp-dev.org!!!

    ___

    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.

    <?php

    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>

    <?php
    }

    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">

    <li>
    <?php bp_friend_o_avatar_thumb_mini() ?>
    </li>
    </div>
    <?php }

    function Widget_ng_fs_o_usersidebar($args) {
    global $bp;
    extract($args);
    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;
    ng_fs_o_usersidebar();
    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");

    ?>

    @nicolagreco

    Participant

    @ngsonst The code you’ve written is a bit wrong, you should read more docs around wp :D

    I couldn’t wait so i’ve just written a new widget that is available in trunk51 @ http://svn.bp-dev.org/trunk :D

    here is the code if you want see :D

    http://trac.bp-dev.org/plugins/browser/trunk/bpdev-widgets/bpdev-widgets-friends-online.php

    Thanks guys

    Nicola

    @johnjamesjacoby

    Keymaster

    Looks like you’ve got this one under control. I’m gonna green light it.

    Thanks for your help!

    @ngsonst

    Participant

    Thanks from me too! And yes, i should read more about that stuff! i took a brief look at your code and i am little bit relieved not to be totally wrong. on the other hand not right, so i will take a closer look soon. i think after my upcoming exams i will get deeper into the wp and bp coding, but first things first. ;-) working with code is for now only a hobby. thanks again!

    @nicolagreco

    Participant

    It’s an hobby for me too, helping other with few lines is the thing i like best :)

    You’ll ever get if you give

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘friends online widget plugin extension’ is closed to new replies.
Skip to toolbar