Skip to:
Content
Pages
Categories
Search
Top
Bottom

Mutual Friends Online status Display


  • swiftblack
    Participant

    @swiftblack

    Good day people…
    I have an idea and I’m really having a hard time implementing it….
    what i would like to do; is to display the online status of mutual friends or buddies in
    a members loop…

    Have tried so many code but i only end up getting the “online” for all users….

    Pls help a brother out…

    THank you

    function mutual_login_user() {
                if ( bp_loggedin_user_id() ) {
        ?>
        <script type="text/javascript">
         jQuery(document).ready(function(){
             jQuery("#mutualfix .kleo-online-status").css("background-color", "yellow");
         });
         </script>
        <?php
                }
        }
    add_action ( 'bp_member_online_status', 'mutual_login_user' );
    
Viewing 16 replies - 1 through 16 (of 16 total)

  • Henry Wright
    Moderator

    @henrywright

    Hi @swiftblack

    Take a look at my plugin Here: https://github.com/henrywright/here

    I use the WordPress Transients API to output a user’s online status. You could easily adapt it for use with BuddyPress.


    swiftblack
    Participant

    @swiftblack

    trying it out… will give you feedback soon
    Thanks very much @HenryWright


    swiftblack
    Participant

    @swiftblack

    Great plugin; but the online status only display on the blog site… but what i want, is to have have it displayed on both blog and buddypress or better still buddypress only….

    Thanks for your help …really appreciated …

    Hope you can share more ideas @henrywright


    Henry Wright
    Moderator

    @henrywright

    Great plugin; but the online status only display on the blog site

    Thanks! As I mentioned it’s a WordPress plugin so you will need to adapt it for use with BuddyPress. It shouldn’t be too difficult to do because BuddyPress members and WordPress users are the same.


    swiftblack
    Participant

    @swiftblack

    @henrywright i was wondering if i could replace this

    return $author . '<img src="' . plugins_url( 'images/dot.png', dirname( __FILE__ ) ) . '" class="here" alt="">';
    

    with

    
    return $author . '<span class="wp_online_notice"></span>';
    

    because anytime i try using any other tag it doesn’t seem to work..

    and moreover, when hovering over the avatar image the tooltip gives out too much details…
    like the exact location of the image and class used as well… which i think is pretty dangerous….

    Thank You


    Henry Wright
    Moderator

    @henrywright

    You can certainly add the span tag instead.

    Why do you think giving the location of the image is dangerous?


    swiftblack
    Participant

    @swiftblack

    @HenryWright

    Thanks fro the reply…..
    but what i would want to do; is to remove the image file and replace it with a html tag..
    what i mean is; instead of using the image <img src="'........ i would rather want to use use a <div id="something" class="something2"></div> to design the green image…. been trying it out but not really working….

    Please Help me out…. IF you can write the the line of code for me … I would be much grateful…. Thank YOU once again


    Henry Wright
    Moderator

    @henrywright

    You could try this

    return $author . '<span class="wp_online_notice"></span>';


    danbp
    Participant

    @danbp

    Hi @swiftblack,

    add this to bp-custom and give it a try.

    It will output on/offline on loggedin member friends profile (only).

    function swiftblack() {
    
    $is_friend = friends_check_friendship( bp_displayed_user_id(), bp_loggedin_user_id() );
    
    $last_activity = bp_get_user_last_activity( bp_displayed_user_id() );
    
    $curr_time = time(); 
    $diff = $curr_time - strtotime( $last_activity );
    $time = 10 * 60;  // 10mn - must be in seconds
    
    	if ( bp_is_user() ):
    
    		if( $is_friend && !bp_is_my_profile() && $diff < $time ) {
    			echo '<br/><span class="on-line">Online</span>'; 
    		//echo '<span class="genericon genericon-dot"></span>'; // see https://genericons.com/
    		} 
    
    		if( $is_friend && !bp_is_my_profile() && $diff > $time ) {
    			echo '<br/><span class="off-line">Offline</span>'; 
    		}
    
    	endif;
    }
    add_action( 'bp_profile_header_meta', 'swiftblack' );

    swiftblack
    Participant

    @swiftblack

    Thanks @danbp and @henrywright for your support .. you guys are amazing with the time you spend in helping others …

    @dandp … will try your function out and give you feedback ASAP.. tHanks AGAIN


    swiftblack
    Participant

    @swiftblack

    @danbp i really appreciate your help

    but unfortunately i tried the code but didn’t work may be im missing something
    🙁


    danbp
    Participant

    @danbp

    It works for me…. where did you add that snippet ? And have you removed your previous custom work around this ?


    swiftblack
    Participant

    @swiftblack

    good day people

    @danbp

    I actually created the bp-custom.php as said and add the code there… it doesn’t give me any error or break my team …it just doesn’t give any feedback… I mean the code jus sit there with on action or maybe not visible to me ….

    I jux don’t know what really is the problem anymore 🙁


    danbp
    Participant

    @danbp

    Have you tested with a twenty theme ? To ensure that the profile hook is working, add this snippet directly to kleo’s functions.php. If it shows TEST, it’s ok and you can remove this snippet.
    Do the same from within bp-custom, should be ok too. If not, yo have to search what goes wrong.

    Activate also wp-debug in wp-config while testing.

    function swiftblack_test() {
    
    echo '<h2>TEST</h2>';
    }
    add_action( 'bp_profile_header_meta', 'swiftblack_test' );

    swiftblack
    Participant

    @swiftblack

    ok thanks @danbp… will get back with feedback when done testing… later


    swiftblack
    Participant

    @swiftblack

    hello good day

    @danbp
    yes it did work…
    i mean the last code… the “TEST” was displayed…. but i only added it to the function.php..
    will try the first code again and see how far it goes..

    or if you can help out..would love that as well

    thanks man

Viewing 16 replies - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.
Skip to toolbar