Hello,
I’m trying to add a button so nonregistered users can contact register users from the profile page via private message.
Saw this discussion here:
https://buddypress.org/support/search/private+message+button/
But nothing worked for me. My website is not in English, should it be a problem? It looks like it bp-custom.php is not recognized, tried inserting the codes to function.php as well. Nothing works…
I’d be happy for some help here.
Tnx
Hello,i want to add an “star with me” button next to the button”private message””public message””add friend”buttons in member’s profile.now the chat plugin provider has told the Api to star the chat box ,it is a The JS function:
FlyzooApi.startChat(LocalUserId, SuccessCallback(), FailCallback()) .
i searched a lot about it but it is too hard for me to solve this question,now i wish to get help.
While using the “Private Message” button, Buddypress is displaying my own name and profile photo (must be grabbing from members-loop, or something) at the top of the screen.
I’d like to make a modification to change this, so that it will display the recipient’s name/photo instead. This way, my users will be looking at the person they are contacting, while entering their message, instead of looking at themselves. It will serve as a reminder of who they are writing to. (Some people forget things very quickly!)
I’ve carefully reviewed the compose.php file, but am I even looking at the right file to make these changes?
Whether it’s the right file or not, does anyone know exactly how I should go about making this change?
If this sounds too complicated, then perhaps you can suggest how to add a line of text like this, right before the Subject field:
This message is to: (Recipient’s Name)
(That would be better than nothing!)
first of all, i’m new to the plugin and wordpress and i am building a website with community features. feel free to tell me about some cool plugins that hook into buddypress to add functionality (i already know about bbpress).
_____________________________________________________
on the wordpress dashboard in settings, buddypress, components, there is an unchecked feature named “site tracking”. what is this exactly and what does it do?
i am using the buddypress login widget. the only tabs it has are the user name and the logout button. is there a way to add more tabs to this like friends, private messages, forum topics (when bbpress is installed), etc?
in the options menu i can enable/disable users uploading profile picture and cover picture. is there an option to limit whether they upload a photo to the site or use a url to post the photo? can i make it so that i can select stock images for user to choose their profile picture and cover picture from?
i notice there is also support for additional community interaction like grouping and posting on group pages. is there a way for users to have their own personal mini blogs that can be viewed by other users?
how would i go about customizing the design/layout of user profiles?
any other advice for me?
I would like to add a ‘send private message’ button in a page, does anybody know how?
Hi all,
I’m using the latest version of BuddyPress & found a bug in the private message modul.
When I write a new message to a member and forget the subject line there is an error message to fill out the subject line –> that’s correct.
But after fill out the subject line and send on the “send” Button, there is another error message, that the username is not correct! –> that’s the bug. When I fill out the subject line and the body-text in one step, the message can be send without any problems.
Is this a general bug in BuddyPress?
Best regards
Miriam
http://www.familyship.org
Hi, Is it possible to add a “private message” button in the members’s directory page.
I have found this
but it is not working when I put it in the “bp-custom.php” file.
Any other ideas?
Thank you.
do you remember that in the user profile appear as buttons to write private or public messages?
I would like to add more buttons (and I did it – I do not remember which files have changed…) but I wish these buttons are only visible in your profile and not at all (thus the reverse of what happens to the buttons of the listed messages above). How can I do? thank you
Hi,
I would out the Private Message Button in a WordPress Page that I use as Dashboard for the members of my website.
I would be able to create a Shortcode to Add the “Private Message” Button to the make to make any member able to send me a Private Message directly to me (only to me from the Dashboard).
1 – The first problem that I have is that I don’t know how to make the button to make eveyrbody able to contact me.
2 – I would use it like a shortcode to insert it everywhere it is necessary.
Please, how can I do it?
I really need support to do it.
Kind regards
G. Aloe
Thank you so much for this code! I’ve spent several hours trying to use other people’s code to hide the button and even tried to make my own but nothing worked until I found your code. I just switched it around because I only wanted one particular group to not be able to send messages while the rest can.
Posting in case someone in the future needs the opposite of your code:
add_filter( 'bp_get_send_message_button', function( $array ) {
if ( pmpro_hasMembershipLevel('NAMEOFPMPLEVEL') ) {
return '';
} else {
return $array;
}
} );
Also, I am looking for the same code as you to restrict non-paying users from sending private messages. I found a code that looks promising but unfortunately doesn’t work. It sees if the user is logged in and if not redirects them. Then if the person is logged in it checks their role but if they’re not that role they’re supposed to be redirected. But it just breaks my whole site. Any ideas?
function my_function() {
if ( ! is_user_logged_in() && bp_is_current_component( 'messages' ) ) {
// Current user is not logged in so don't let them see stuff. In this case, private messages
wp_redirect( home_url() );
exit;
}
$flag = false;
// Get current user info.
$user = wp_get_current_user();
if ( ! in_array( 'student', $user->roles ) ) {
// The current member is not a student.
$flag = true;
}
if ( $flag && bp_is_current_component( 'messages' ) ) {
The currently logged-in member is not a student and is trying to view private messaging. Let's redirect them away.
wp_redirect( home_url() );
exit;
}
}
add_action( 'init', 'my_function' );
This works and hides the button, but I’m curious. Can someone still send a private message to another user when they are “not” friends using URL manipulation or should the _wpnonce stop that?
1) If is text of private message too long, do read more
2) Seen date – please do date with time (date & time reading)
3) Why is there SSS? Please change text on “Mark as read” and “Mark as unread” It confuses people
4) When someone wants to see the messages in the conversation, please do that he will automatically jump down the page on the last message. Look how it works on Facebook, it also jumps down and you do not have to scroll down in order to write the answer.
5) Load more button – In some of the conversations I have more than 30 messages, then it’s confusing. Load newest button – Could you indicate a new incoming message as in the activities?
6) New messages at the top, old messages down. Similar as is the case activity. Reply form at the top as well.


hi @masoud1111,
all i found was how to hide that button, or remove it.
but not show it only on some profiles
You just need to add some conditionnals.
Try this (in bp-custom.php) and give feed back if it works.
function bpex_private_message_button( $button ) {
$user = bp_loggedin_user_id();
if ( is_super_admin() ) {
return $button;
}
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
if ( $role == 'subscriber' || $role == 'contributor' || $role == 'author' || $role == 'editor' ) {
// hide button for these roles
$button = '';
}
}
// allow the button to appear on admin's profile only
if ( bp_is_active( 'xprofile' ) && bp_is_user() ) {
$user_id = bp_displayed_user_id();
// assuming admin's ID is 1
if ( $user_id == 1 ) {
return $button;
}
}
}
add_filter( 'bp_get_send_message_button', 'bpex_private_message_button', 1 , 1 );
hi.
i am using latest version of BP and WordPress.
and i am working on a food & recipe website.
in this website, i’d like to show the “private message” button only on admin’s page.
something with the help of:
if (current_user_can(administrator) && is_admin())
{ \\show the button on his profile }
else
{ \\hide the button on profiles }
Or maybe:
if(current_user_id == 1) \\for example user 1 is admin
{ \\show the message button on his profile for others to see }
—–
as an example: imagine you have 4 users. user A, user B, user C, user D.
Role user A : admin
Role user B & C & D : subscribers/or/authors/or/editor/or…
subscribers can’t see the private message button on each others profile page to send each other message.
but when they visit User A profile page, they can see the button , and can send message only to admins…
i searched a lot, but all i found was how to hide that button, or remove it.
but not show it only on some profiles for others to see .
any help would be much appreciated.
thanks a lot.
The function is working correctly on my install.
Perhaps you have an issue with quotes, ie after copy/pasting the snippet from a topic where the code whas inserted without using the code button.
Which software do you use to publish bp-custom ?
Copy/paste following and give a try:
function buddydev_hide_members_directory_from_all_except_admin() {
if ( bp_is_members_directory() && ! is_super_admin() ) {
//should we add a message too?
//bp_core_add_message( 'Private page.', 'error' );
bp_core_redirect( site_url('/') );
}
}
add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_from_all_except_admin' );
This topic is titled “Function to hide private message depending of user role”.
and the snippet does that ! Subscribers have no access to the button. So far i remember it is also the default role in WordPress. You change that to your need.
The first condition in the snippet allows some users (by ID) to access the button, whatever their role.
If you want to add other WP roles, you simply copy the 2nd conditionnal if(role=='') and add another role if(role=='mamamouchi") { //do something }.
Or you use only the user ID if you have only a few members allowed to access. I litle understanding of php is of course a + to do that.
You have the basics in the snippet. Now, it’s to you now to make it work for your need.
Thank you @danbp, this work ! I’m pretty sure this will help a lot (and not only me).
I’am asking something more : can this be adapt to allow only some user role to use private message ? (and not only some users ?) As the second part of the code you wrote, it remove the button to susbscriber.
(I’m learning PHP, I’ve tried to change the code but did not succeed to have it work…)
Hi,
try this (goes to bp-custom.php)
function bpex_remove_private_message_button( $button ) {
$user = bp_loggedin_user_id();
if ( $user == '4' || $user == '7' || $user == '25' ) { // the allowed user ID's
return $button;
}
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
if ( $role == 'subscriber') {
$button = '';
}
}
}
add_filter( 'bp_get_send_message_button', 'bpex_remove_private_message_button', 1 , 1 );
No idea how to get specifically a pmpro defined user ID – you have to check their doc to adjust the above snippet. Note that it works on a standart install – without pmpro.
Hi !
I’ve been looking for this function on the forum but did not find something about my pb on the forum. I need to disable private messaging for some members. My website runs PMPRO but if a function can help me doing this, I’m OK with it.
For example, I need users only with the WP role “premium1” to be allowed to send private message;
OR, it can be users only with pmpro membership level “6” to have access to this function and see the “Private message” button.
Does someone has a solution for me ? (bp-custom or function.php from child-theme)
Thanks !
Hi @koded1999,
please, use the <code> button to insert snippets. Also avoid double posting.
Closing this topic as duplicate.
Conversation goes ahead here:
Disable or Hide Private Message Button
@henrywright i managed to fix that and is working perfectly.
but i have another problem.
i will like to populate the subject automatically when user click the private message button from post
pls how can i achieve this.
thank you
@henrywright Please i will like to add private message button in post side bar. i used the code below it works but doesnt populate the author automatically. how can i fix this thanks in advance.
function bpfr_message_shortcode() {
$author = get_the_author();
$message = 'Login to contact advertiser!';
if( is_user_logged_in() ) {
return '<a>MESSAGE ADVERTISER</a>';
} else {
return $message;
}
}
add_shortcode( 'ksam', 'bpfr_message_shortcode' );
I have this very specific problem I need to solve. The thing is I have this BuddyPress-Setup that is linked to my WP and WC Vendors. What I’m trying to achive is a sidebar/seller info tab displaying the BuddyPress-Profil informations from the Vendor. Something like this when the User is logged in:
- Profile name (BuddyPress/WP)
- Storename (from WC Vendors)
- phone number
- email-address
- Button to send Private Message to Seller
If the User is not logged in there should be a Button with the meassgae to please login. I already know how to do that button.
I already linked my BuddyPress Profile with the WC Vendors store. So that the “Visit-Store”-Button is displayed on the BuddyPress profile of my Users (from knowledge Base of WC Vendors)
How is the best way to approche this problem?
I’m not looking for a fullywritten out solution just some suggestions where to start.
I’m running the current versions of WP, BuddyPress, WooCommerce and WC Vendors(free) with the Socialize Theme. Also posted the question on the WC Vendors Support Site.
Thank you for your help.
Hi,
you can try to remove the private message button from the template or hide it with CSS.
And add a custom one who leads to admin inbox.
The link should look like
http://your-site.com/members/YOU/messages/compose/?r=THE ADMIN&_wpnonce=an_alpha_numeric_value
See here how you may code this
Codex and Forum are your friends to search about template customization.