This topic has 9 replies, 3 voices, and was last updated 10 years by aztlanla.

  • Author
  • #6260
     aztlanla
    Participant

    Hi, I was able to add online/offline status to the members page, but have not been able to add it too the profile page. Can you help with this?

    Also, I added a chat button to the profile page, how can make the chat button appear only when the member is online?

    Thanks again

    #6264
     JohnDoe
    Participant

    Could you share the online/offline code?

    #6313
     SQadmin
    Keymaster

    The online/offline will be included this month in 2.3 update.

    To check if online, see this topic: https://archived.seventhqueen.com/forums/topic/check-if-user-is-online#reply-5149

    if you are on a profile page you need to replace bp_get_member_user_id() with bp_displayed_user_id()

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

    Thanks I was able to get the Online status to work under profile.

    I edited this file

    /wp-content/themes/sweetdate-child/members/single/members-header.php

    and added

    COPY CODE
    
    <?php if (kleo_is_user_online(bp_displayed_user_id())) { echo '<FONT COLOR="black"><b>Online</b></FONT>'; } else { echo "Offline"; } ?>
    

    right above

    COPY CODE
    
    <div class="row">
    

    But still can’t get the chat button to appear if online and disappear if offline.

    #6441
     SQadmin
    Keymaster

    It should be the exact sentence but instead of echo-ing the online status, you echo the button

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

    I had tried that before, maybe I’m not escaping it correctly.

    Here’s the code I used.

    COPY CODE
    
    echo '<button type="button" onclick="javascript:jqcc.cometchat.chatWith('<?php echo bp_displayed_user_id() ?>');">Instant Message</button>';
    

    I had it placed in place of echo-ing the online status, but it does not work. I get the page to error out.

    #6528
     SQadmin
    Keymaster

    You have some strange single quotes.. replace them with the regular ‘ from the keyboard

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

    Those are the same quotes I have throughout the members-header.php.
    I deleted the single quotes and typed them in again, they look exactly the same.

    Here is the whole line

    COPY CODE
    
    <?php if (kleo_is_user_online(bp_displayed_user_id())) { echo '<button type="button" onclick="javascript:jqcc.cometchat.chatWith('<?php echo bp_displayed_user_id() ?>');">Instant Message</button>'; } else { echo "Offline"; } ?>
    

    Here is the error that comes up on the page.

    COPY CODE
    
    Parse error: syntax error, unexpected '?' in /wp-content/themes/sweetdate-child/members/single/member-header.php on line 51
    
    #6612
     SQadmin
    Keymaster

    You haven’t added it right.. you need basic php knowledge:

    <?php if (kleo_is_user_online(bp_displayed_user_id())) { echo '<button type="button" onclick="javascript:jqcc.cometchat.chatWith('. bp_displayed_user_id().');">Instant Message</button>'; } else { echo "Offline"; } ?>
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #6708
     aztlanla
    Participant

    That worked thanks.

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

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?