This topic has 11 replies, 2 voices, and was last updated 8 years by sharmstr.

  • Author
  • #87673
     Oscar570
    Participant

    Hi !

    I’d like to insert a button to ask a member for a CHAT instead of SEND A PUBLIC MESSAGE. I’m using COMETCHAT. I contacted them and they said to me :

    “<span style=”color: #333333;font-family: Verdana, sans-serif;font-size: 11px”> </span><span style=”color: #333333;font-family: Verdana, sans-serif;font-size: 11px”>Add button or link with below code on click of which it should open chat window for the user.
    </span>

    <span style=”color: #333333;font-family: Verdana, sans-serif;font-size: 11px”>Chat with me“</span>

     

    BUT I don’t know to do it.

    How can I do this ? Can you help me?

    Thanks a lot

    Regards

    Nathalie

    #87689
     sharmstr
    Moderator

    I obviously cant test this, but something like this should work. Put it in your child theme’s functions.php file.

    COPY CODE
    // Removing public message option
    
    function remove_public_message_button() {
        remove_filter( 'bp_member_header_actions','bp_send_public_message_button', 20);
        // Add chat button
        add_action( 'bp_member_header_actions','add_chat_button',20);
    
    }
    add_action( 'bp_member_header_actions', 'remove_public_message_button' );
    
    function add_chat_button() {
        echo '<div class="generic-button"><a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(userid);">Chat with me</a></div>';
    }
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #87698
     Oscar570
    Participant

    Dear Sharmstr,

    The button is remove by “CHATTER” (instead of CHAT WITH ME) but nothing is happening…

    Attachments:
    You must be logged in to view attached files.
    #87700
     sharmstr
    Moderator

    Perhaps because of their code. How are they getting ‘userid’?

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

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #87701
     Oscar570
    Participant
    This reply has been set as private.
    #87703
     Oscar570
    Participant
    This reply has been set as private.
    #87705
     sharmstr
    Moderator

    bp_displayed_user_id() will return the userid of the profile you are viewing. So, you can try the following. If it doesnt work, you’ll have to hire someone to get it working for you.

    COPY CODE
    // Removing public message option
    
    function remove_public_message_button() {
        remove_filter( 'bp_member_header_actions','bp_send_public_message_button', 20);
        // Add chat button
        add_action( 'bp_member_header_actions','add_chat_button',20);
    
    }
    add_action( 'bp_member_header_actions', 'remove_public_message_button' );
    
    function add_chat_button() {
        echo '<div class="generic-button"><a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith(' . bp_displayed_user_id() . ');">Chat with me</a></div>';
    }
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #87707
     Oscar570
    Participant

    ok Where must I add this code please ?

    #87708
     sharmstr
    Moderator

    In the same place you did before. I gave you updated code that uses bp_displayed_user_id to get the userid. So delete the old code and add the new code.

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

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #87711
     Oscar570
    Participant

    Perfect !
    Thanks a lot!

    #87827
     Oscar570
    Participant

    Dear Sharmstr,

    I used COMETCHAT.
    From the side menu (who become my mobile menu) I’d like to insert a button on this menu to launch COMETCHAT Application. How can I do this please ?

    #87875
     sharmstr
    Moderator

    What’s the code you need to use? The code you gave me before was to launch a chat with a specific user. That wont work in the side menu since the side menu shows on every page.

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

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

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

The forum ‘Plugins questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?