-
Author
-
November 17, 2015 at 13:26 #87673
Oscar570
ParticipantHi !
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
November 17, 2015 at 14:23 #87689sharmstr
ModeratorI 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 solutionNovember 17, 2015 at 15:01 #87698Oscar570
ParticipantDear Sharmstr,
The button is remove by “CHATTER” (instead of CHAT WITH ME) but nothing is happening…
November 17, 2015 at 15:08 #87700sharmstr
ModeratorPerhaps 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 solutionNovember 17, 2015 at 15:16 #87701Oscar570
ParticipantDear Sharmstr,
This is their answer to my question : How can I insert a button on Buddypress for asking a chat to a member? :
“Is it possible to insert “CHAT” to the buddypress menu. And when you click on you can ask chat with somebody ?
Please follow below steps to implement chatWith API on profile page of a user:
a. Make sure CometChat footer code is added in your site’s template file so the CometChat bar is visible on your site.
b. Add button or link with below code on click of which it should open chat window for the user.You can access userid by following methods, for example:
1. If userid is passed in URL when you are on other user’s profile page then you can access userid from URL and then pass it to chatWith() function.
2. If you are having a hidden field on profile page which stores userid of the user on whose profile page we are, then you can access that hidden field by its attribute (example id) and pass it to chatWith() function
3. If Profile picture or name on profile page of that user has a field that can allow us to access userid id then you can pass that userid to chatWith() with help of field or function( example get_the_author_meta() function in wordpress).”
November 17, 2015 at 15:22 #87705sharmstr
Moderatorbp_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 solutionNovember 17, 2015 at 15:33 #87708sharmstr
ModeratorIn 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 solutionNovember 18, 2015 at 10:49 #87827Oscar570
ParticipantDear 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 ?November 18, 2015 at 15:12 #87875sharmstr
ModeratorWhat’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 -
AuthorPosts
The forum ‘Plugins questions’ is closed to new topics and replies.