Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to send private massage only support person’s role not anyone in buddypress

  • @anonymized-16484011

    Inactive

    Hi !

    Is it possible in buddypress that users only sent message to support person’s role. OR Specific person’s name already added to massage’s sent to field. Users can’t change it or just direct type subject and message than sent.

    Regards

Viewing 14 replies - 1 through 14 (of 14 total)
  • @prashantvatsh

    Participant
    function ps_remove_private_message_button( $button ) {
            $user = bp_displayed_user_id();
    	if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
    		if ( $role != 'your_role_here') {
    			$button = '';
    		}
    	}
         return $button;
    }
    add_filter( 'bp_get_send_message_button', 'ps_remove_private_message_button', 10 , 1 );

    Hi,

    One solution is to hide private message button from any other user roles and just leave on support user role. Please try the above-given code for the same.

    Thanks

    @anonymized-16484011

    Inactive

    No,

    I think I can’t explain my problem very well. I want to that type of settings for my all users to send message to only support person. For example Sent to field automatically has “support” word and user can’t edit so users have to only two field remaining subject and message. So, in this settings users can only sent a message to support person only. Not any other.

    Thanks

    @prashantvatsh

    Participant
    add_action( 'messages_message_before_save', 'ps_manage_sending_of_private_message',10,1 );
    function ps_manage_sending_of_private_message( $message_object ) {
    	$receivers = $message_object->recipients;
    	foreach($receivers as $receiver){
    		$receiver_id = $receiver->user_id;
    		$user = get_userdata( $receiver_id );
    		$user_roles = $user->roles;
    		if ( !in_array( 'your_role_here', $user_roles ) ) {
    			$message_object->recipients = false;
    		}
    	}
    }

    Another solution is that, if the user added in the recipient list is not of the role that you want then do not send/save messages.

    Please try this also, if do not want the first one.

    Thanks

    @prashantvatsh

    Participant

    For example Sent to field automatically has “support” word and user can’t edit so users have to only two fields remaining subject and message. So, in this settings, users can only sent a message to support person only. Not any other.

    So ‘support’ will be a user, right?

    @anonymized-16484011

    Inactive

    Unhh !

    I used above but here users have to type in the sent to field of mail. I want to restrict users to type in send to field and I already added word support(for support person’s username) here and users noew only type subject, message and send.

    Thanks for helping me …

    @prashantvatsh

    Participant

    I will try to code a snippet for this, will let you know soon. You have the user id of the support user, right?

    Thanks

    @anonymized-16484011

    Inactive

    Yes I have the userid, email-id and anything you want to put in your code which is use to send buddypress member to send a message. You use anything in your code you are comfortable with it.

    Thanks

    @prashantvatsh

    Participant

    Hi,

    It seems like with the new template we can not do too much changes because it runs an ajax request to fetch the details of an user and then it works but still please try this code:

    add_filter( 'get_footer', 'ps_fill_user_name' );
    function ps_fill_user_name(){
    	if (bp_is_messages_compose_screen()) {
    		?>
    		<script type="text/javascript">
    			jQuery(document).ready(function(){
    				jQuery('#send-to-input').val('@test');
    				jQuery('#send-to-input').attr('readonly','readonly');
    			});
    		</script>
    		<?php
    	}
    }

    Change @test with your username.

    Thanks

    @anonymized-16484011

    Inactive

    Sorry Prashant for silly questions !

    But where can I past this code ? Which file and before or after which line.

    I am new bee for buddy press !

    Regards

    @prashantvatsh

    Participant

    You can use a plugin called code snippets abd there add a new snippet then paste this code there.

    @anonymized-16484011

    Inactive

    Hi !

    On your above solution if admin want to message anyone he select the person from members page and click on message button and than compose screen has the name of the person shown and in the to button shows “support” in ready only mode which can not change by admin.

    So, If we want to give permission to change this read only “support” word.

    Is it possible ?

    Thanks

    @prashantvatsh

    Participant
    add_filter( 'get_footer', 'ps_fill_user_name' );
    function ps_fill_user_name(){
    	if (bp_is_messages_compose_screen()) {
    		?>
    		<script type="text/javascript">
    			jQuery(document).ready(function(){
    				jQuery('#send-to-input').val('@test');
    				jQuery('#send-to-input').attr('readonly','readonly');
    			});
    		</script>
    		<?php
    	}
            if (current_user_can('manage_options')) {
              ?>
    	  <script type="text/javascript">
    		jQuery(document).ready(function(){
    			jQuery('#send-to-input').removeAttr('readonly');
    		});
    	   </script>
    	<?php
            }
    }

    @anonymized-16484011

    Inactive

    Hi !

    Prashant,

    It’s work perfectly !

    Thanks Man ! Heads off you !

    Regards

    @prashantvatsh

    Participant

    Glad to know that it worked for you 🙂

    Thanks

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.
Skip to toolbar