This topic has 5 replies, 2 voices, and was last updated 10 years by Abe.

  • Author
  • #8262
     Snake24
    Participant

    Hi,
    I have made much modifications on your template and now i have seen the new version features.
    I would like to add only the online indicator.
    I have paste this code in my bp-functions.php (/custom_buddypress/bp-functions.php)

    /* User online */
    if (!function_exists(‘kleo_is_user_online’)):
    /**
    * Check if a Buddypress member is online or not
    * @global object $wpdb
    * @param integer $user_id
    * @param integer $time
    * @return boolean
    */
    function kleo_is_user_online($user_id, $time=5)
    {
    global $wpdb;
    $sql = $wpdb->prepare( ”
    SELECT u.user_login FROM $wpdb->users u JOIN $wpdb->usermeta um ON um.user_id = u.ID
    WHERE u.ID = %d
    AND um.meta_key = ‘last_activity’
    AND DATE_ADD( um.meta_value, INTERVAL %d MINUTE ) >= UTC_TIMESTAMP()”, $user_id, $time);
    $user_login = $wpdb->get_var( $sql );
    if(isset($user_login) && $user_login !=””){
    return true;
    }
    else {return false;}
    }
    endif;

    if (!function_exists(‘kleo_online_status’)):
    /**
    * Render the html to show if a user is online or not
    */
    function kleo_online_status() {
    if (kleo_is_user_online(bp_get_member_user_id())) {
    echo ‘<span class=”online”></span>’;
    } else {
    echo ‘<span class=”offline”></span>’;
    }
    }

    if (sq_option(‘bp_online_status’, 0) == 1) {
    add_action(‘bp_members_inside_avatar’, ‘kleo_online_status’, 9);
    }
    endif;

    and i have paste this to default.css (in /custom_buddypress/_inc/css/default.css)

    /* User status */
    #members-list .search-item .avatar {
    position: relative;
    overflow: visible !important;
    }
    .avatar span.online,
    .avatar span.offline {
    position: absolute;
    display: block;
    top: 2px; right: 2px;
    z-index: 10;
    content: ‘ ‘;
    width: 16px;
    height: 16px;
    border: 3px solid #fff;
    border-radius: 50%;
    }
    .avatar span.online {
    background: #33cc33;
    }
    .avatar span.offline {
    background: #cccccc;
    }

    The indicator doesn’t show on my members page. How can i do to add it?
    Thanks
    Regards

    #8324
     Abe
    Keymaster

    Hi, also change the file members/members-loop.php

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #8363
     Snake24
    Participant

    Changed but not solved.
    Actually i have modified 3 files:

    members/members-loop.php
    custom_buddypress/bp-functions.php
    custom_buddypress/_inc/css/default.css

    How can i solve it?

    #8414
     Abe
    Keymaster

    THe code you pasted in bp-functions.php is correct. You need to add this missing line in members-loop.php

    That should be all beside the CSS

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #8550
     Snake24
    Participant

    Added but not solved:

    <?php

    /**
    * BuddyPress – Members Loop
    *
    * Querystring is set via AJAX in _inc/ajax.php – bp_dtheme_object_filter()
    *
    * @package BuddyPress
    * @subpackage bp-default
    */

    ?>

    <?php do_action( ‘bp_before_members_loop’ ); ?>

    <?php if ( bp_has_members( bp_ajax_querystring( ‘members’ ). ‘&per_page=’.sq_option(‘buddypress_perpage’) ) ) : ?>

    <?php do_action( ‘bp_before_directory_members_list’ ); ?>

    <div class=”item-list search-list” id=”members-list”>
    <?php while ( bp_members() ) : bp_the_member(); ?>

    <div class=”four columns”>
    <div class=”search-item”>
    <div class=”avatar”>
    <?php bp_member_avatar(‘type=thumb&width=94&height=94&class=’); ?>
    <?php do_action(‘bp_members_inside_avatar’);?>
    </div>
    <?php do_action(‘bp_members_meta’);?>
    <div class=”search-body”>
    <?php do_action( ‘bp_directory_members_item’ ); ?>
    </div>
    <div class=”bp-member-dir-buttons”>
    <?php do_action(‘bp_directory_members_item_last’);?>
    </div>
    </div>
    </div>

    <?php endwhile; ?>
    </div>

    <?php do_action( ‘bp_after_directory_members_list’ ); ?>

    <?php bp_member_hidden_fields(); ?>

    <!– Pagination –>
    <div class=”row”>
    <div class=”twelve columns pagination-centered”>
    <div class=”pagination” id=”pag-bottom”>
    <div id=”member-dir-pag-bottom” class=”pagination-links”>
    <?php bp_members_pagination_links(); ?>
    </div>
    </div>
    </div>
    </div>
    <!–end Pagination–>
    <?php else: ?>

    <div id=”message” class=”alert-box”>
    <?php _e( “Sorry, no members were found.”, ‘kleo_framework’); ?>
    </div>

    <?php endif; ?>

    <?php do_action( ‘bp_after_members_loop’ ); ?>

    #8622
     Abe
    Keymaster

    I don’t know what other code/customization you have added. Maybe the functions are added in your child theme and are overriding default ones…. Install the theme is a test location if you want to see how it should be

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?