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.
trying it out… will give you feedback soon
Thanks very much @HenryWright
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
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.
@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
You can certainly add the span tag instead.
Why do you think giving the location of the image is dangerous?
@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
You could try this
return $author . '<span class="wp_online_notice"></span>';
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' );
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
@danbp i really appreciate your help
but unfortunately i tried the code but didn’t work may be im missing something
🙁
It works for me…. where did you add that snippet ? And have you removed your previous custom work around this ?
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 🙁
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' );
ok thanks @danbp… will get back with feedback when done testing… later
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