Search Results for 'private message button'
-
AuthorSearch Results
-
June 25, 2018 at 6:12 pm #274732
In reply to: Private Message Button Not Working Right?
RT77
Participantanyone? this is on buddypress profiles.. all plugins are deactivated so nothing is interfering as far as I know. When the “Private Message” Button is clicked it does not open the compose message with the user name in the title.. I think it might be a bug?
June 24, 2018 at 4:55 pm #274677Topic: Private Message Button Not Working Right?
in forum How-to & TroubleshootingRT77
ParticipantHello I think I have a bug here, ok I am on buddypress Version 3.1.0 and logged in as admin I click on a member in the members directory and it has a button for “private message”, when clicked on I am assuming it is supposed to open the compose message box with the members name in the send to field but it is not doing that for some reason. I am assuming this also because of the url link. https://www.theexample.com/members/admin/messages/compose?r=thememberid
So is this a bug and how can I fix this if it is?April 28, 2018 at 5:00 pm #272468In reply to: Create private message button.
taskemann
ParticipantHi Venutis! Thank you for the tip 🙂
But I found this code online created by a fellower named Brajesh Singh that worked very well. I just pasted it into my child theme’s functions.php
////////////////////////////////////////////////////////////////// // BuddyPress send private message button ////////////////////////////////////////////////////////////////// /** * Get a link to send PM to the given User. * * @param int $user_id user id. * * @return string */ function buddydev_get_send_private_message_to_user_url( $user_id ) { return wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( $user_id ) ); } /** * Shortcode [bp-pm-button username=optional_some_user_name] * * @param array $atts shortcode attributes. * @param string $content content. * * @return string */ function buddydev_private_message_button_shortcode( $atts, $content = '' ) { // User is not logged in. if ( ! is_user_logged_in() ) { return ''; } $atts = shortcode_atts( array( 'user_id' => '', 'username' => '', 'label' => 'Send Private Message', ), $atts ); $user_id = absint( $atts['user_id'] ); $user_login = $atts['username']; // if the username is given, override the user id. if ( $user_login ) { $user = get_user_by( 'login', $user_login ); if ( ! $user ) { return ''; } $user_id = $user->ID; } if ( ! $user_id ) { if ( ! in_the_loop() ) { return ''; } $user_id = get_the_author_meta('ID' ); } // do not show the PM button for the user, if it is aimed at them. if ( bp_loggedin_user_id() === $user_id ) { return ''; } // if we are here, generate the button. $button = sprintf('<a href="%1$s">%2$s</a>', buddydev_get_send_private_message_to_user_url( $user_id ), $atts['label'] ); return $button . $content; } add_shortcode( 'bp-pm-button', 'buddydev_private_message_button_shortcode' );November 18, 2017 at 10:26 am #269028naomibuch
ParticipantHello,
I am new to Buddypress and this is my first post, I am new to web development also, and my PhP coding is not all that great, my years as a software developer was strictly in a windows environment (vb.net and sql)
I developed my own website and I am using Buddypress as part of my social media for users to connect with each other.
I have spent endless hours researching a fix, and I have not been able to find anything php file that I can edit in File Manager to edit or remove the line of code.
When a user updates an Activity, it updates in three places:
1. The Activity Stream (which is what I want)
2. The Member’s Profile where the Activity tab was (now removed, which is what I want)
3. Under the Member’s profile cover, with that pesky “view link” (which I DO NOT want to show)And the “view link” is a bit buggy also, sometimes when a user clicks on it, it throws a 404 error, sometimes it opens up a blank page, and sometimes it opens up the recent activity that they posted in the Activity Stream.
Also in the members directory I have a button to send the user a private message whether or not they are friends.
When I click on a user name from the member’s directory, it take me to the compose a message like it is suppose to do, and the user name appears , but it does not save the user name in the send to box, do you have a fix for this also?
Thank you very much, a fix to these problems are greatly appreciated.
Naomi
November 8, 2017 at 1:59 pm #268891In reply to: Profile buttons not working (fixed)
Boone Gorges
Keymaster@louisarthur – Thanks for sending me credentials. I’ve logged into your site to have a look.
As you note in your email, there’s no
hrefattribute on these links. It’s not clear to me how this would be the case, but I can give you a starting point for looking into it yourself. Briefly, the buttons will be built without anhrefif the button constructing function passes an emptylink_hrefparameter to theBP_Buttonclass. The functions used in the two cases are different:Message public: https://buddypress.trac.wordpress.org/browser/tags/2.9.2/src/bp-activity/bp-activity-template.php?marks=3090#L3079
Message privé: https://buddypress.trac.wordpress.org/browser/tags/2.9.2/src/bp-messages/bp-messages-template.php?marks=1362#L1360
The logic in each case is different, but since neither is showing up, I’m guessing that one of two things is happening:
1. One of the conditional checks shared between them is failing for some reason:
bp_is_my_profile(),is_user_logged_in().2. Something on your installation – perhaps your theme but probably a plugin (since you said Twenty Seventeen was exhibiting the problem as well) – is filtering both ‘bp_get_send_private_message_link’ and ‘bp_get_send_public_message_link’, and then incorrect returning empty strings.
To test idea #2, you might try – if you can – searching through your codebase for those filter names.
October 20, 2017 at 2:52 pm #268591paksunny
ParticipantHi,
I am trying to make the below two changes but tried all different solutions available on this form non worked.
1) Make the friend tab only visible to the account owner / logged-in user.
2) only friends can use and see the send private message button.Can someone guide me to getting this accomplished. Most of the privacy settings I was able to integrate through plugins.
October 4, 2017 at 7:55 pm #268350In reply to: Help with this code
livingflame
ParticipantOkey, here is the correct code, thanks to @brajesh
// Adding message button in members directory function filter_message_button_link( $link ) { $link = wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r='. bp_core_get_username( bp_get_member_user_id() ) ); return $link; } function display_private_message_button() { if( is_user_logged_in() && bp_get_member_user_id() != bp_loggedin_user_id() ) { //bp_send_message_button(); ?> <div id="send-private-message" class="generic-button"> <div class="private-message-button generic-button" ><a href="<?php echo filter_message_button_link(); ?>" class="button small secondary radius" rel="add"><i class="icon-envelope"></i></a></div> </div> <?php add_filter('bp_get_send_private_message_link', 'filter_message_button_link', 1, 1 ); } } add_action( 'bp_directory_members_item_last', 'display_private_message_button',9999 );September 26, 2017 at 9:53 am #268216Topic: HTML Form to private message
in forum How-to & Troubleshootinglofiz
ParticipantI am trying to build a contact form that I can load on any page that would send a private message to a user. I already have the selected user/s in an array and now I would like to take that plus form data to (I’m guessing) message_new_message
Sample HTML Form
<form>
<label>Subject</label>
<input id="subjec_input" name="subject_input" type="text">
<label>Message Body</label>
<textarea id="body_input" name="body_input"></textarea>
<button id="submit_btn" name="submit_btn">Submit</button>
</form>
How I think arguments are given to the function
`messages_new_message( $args = array( ‘recipients’ => $user_id, ‘subject’ => $title, ‘content’ => $message );
Any help would be appreciated. Thanks
September 21, 2017 at 4:43 pm #268157In reply to: Help with this code
livingflame
ParticipantHelp me with the code.
I need the Message button visible only to logged in users (Just like the Add Friend button works).Check the code, please.
// Adding message button in members loop function filter_message_button_link( $link ) { $link = wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r='. bp_core_get_username( bp_get_member_user_id() ) ); return $link; } function display_private_message_button() { if( bp_get_member_user_id() != bp_loggedin_user_id() ) { //bp_send_message_button(); ?> <div id="send-private-message" class="generic-button"> <div class="private-message-button generic-button" ><a href="<?php echo filter_message_button_link(); ?>" class="button small secondary radius" rel="add"><i class="icon-envelope"></i></a></div> </div> <?php add_filter('bp_get_send_private_message_link', 'filter_message_button_link', 1, 1 ); } } add_action( 'bp_directory_members_item_last', 'display_private_message_button',9999 );November 30, 2016 at 7:50 pm #261559danbp
Participantplease use forum’s search before asking !
https://buddypress.org/support/search/private+message+button/For example:
November 16, 2016 at 5:17 am #261060In reply to: Resctrict private messages
empressdianna
ParticipantThank 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' );November 8, 2016 at 9:09 pm #260857In reply to: Disable or Hide Private Message Button
maccast
ParticipantThis 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
_wpnoncestop that?October 30, 2016 at 11:34 pm #260568In reply to: [Resolved] show buddypress private message button
danbp
Participanthi @masoud1111,
all i found was how to hide that button, or remove it.
but not show it only on some profilesYou 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 );October 26, 2016 at 12:26 pm #260381danbp
ParticipantThe 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' );October 11, 2016 at 6:46 pm #259742danbp
ParticipantThis 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 roleif(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.October 11, 2016 at 6:22 pm #259740Raphael.v
ParticipantThank 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…)
October 11, 2016 at 12:33 pm #259719danbp
ParticipantHi,
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.
October 5, 2016 at 5:25 am #259414In reply to: Buddypress PM Message from Post
danbp
ParticipantHi @koded1999,
please, use the
<code>button to insert snippets. Also avoid double posting.
Closing this topic as duplicate.
Conversation goes ahead here:October 5, 2016 at 3:55 am #259413In reply to: Disable or Hide Private Message Button
koded1999
Participant@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
October 5, 2016 at 3:02 am #259410In reply to: Disable or Hide Private Message Button
koded1999
Participant@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' );September 1, 2016 at 8:27 pm #258281In reply to: Private Messaging restriction
danbp
ParticipantHi,
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_valueSee here how you may code this
Codex and Forum are your friends to search about template customization.
August 28, 2016 at 6:56 pm #258149In reply to: [Resolved] Create shortcode for link to post author
August 26, 2016 at 6:57 pm #258094In reply to: New Privacy Plugin
danbp
Participanthi @fencer04,
thank for sharing your work. Well done, but it needs some revision (sorry).
At his activation on 2 test sites (one with 4.5.3/bp 2.6.1, other 4.6/bp2.6.2) i got a notice.
Array to string conversion inbuddypress/bp-core/classes/class-bp-core-nav.php on line 279fromsbpp04_privacy_check( ) ..\plugin.php:525 sbpp04_privacy_redirect( ) ..\buddypress-profile-privacy.php:176 bp_core_remove_nav_item( ) ..\buddypress-profile-privacy.php:184 BP_Core_Nav->delete_nav( ) ..\bp-core-buddybar.php:798Another point concerning UI/UX is the Private button appearing on buddybar.
On this tab, a default message says Friends Only.
USERNAME has chosen to limit profile access to friends only.
That’s wrong! Because this appear on each profile, even if the owner hasn’t setup anything about his profile privacy.So far i understand its fonctionality, this plugin let each member decide to show or not his whole profile page to friends or members only or to everyone (bp default).
– imo this tab should show “This profile is private” to anybody who is concerned by a privacy setting and should not appear at all if “Everyone” is set.
– the original BP Add as friend button on profile header or members directory is still there. This means that there is no need to go on Private tab to ask forfriendship.
This is a little confusing !If the plugin is to extend profile settings, it should appear in profile settings only. And as it doesn’t superseed BP, there is no real reason to give him an extra tab on buddybar outside of the settings scope. A template notice could be enough to tell visitors what’s going on on such a profile.
Just my 2 cents.
August 20, 2016 at 10:40 pm #257833danbp
ParticipantTry this:
function mohammad_remove_private_message_button( $button ) { $user_id = bp_loggedin_user_id(); if ( $user_id == '37' ) // the user ID $button = ''; return $button; } add_filter( 'bp_get_send_message_button', 'mohammad_remove_private_message_button', 1 , 1 );More details here:
June 16, 2016 at 9:29 pm #254713danbp
ParticipantI tested your code and got first a page not found error while trying to send a private message from the new position.
I deactivated both action hook in cover and home files.
Disallowed cover image option. And tested again and everithing worked.
Allowed cover image and worked also.So i confirm that your code works and all buttons show up (with active href’s), at least with Twenty Sixteen theme, at the members profile page bottom.
In resume, the only thing you have to do is to deactivate the original action hook in both files (so you can allow/disallow cover images).
Forgot to mention that there is a litle error in your code line 133
<?= wpautop(xprofile_get_field_data("About me", bp_displayed_user_id() ) ); ?>Should be
<?php wpautop(xprofile_get_field_data("About me", bp_displayed_user_id() ) ); ?> -
AuthorSearch Results