is it possible that User only can sent the message to the network admin !

I am using the messaging plugin in my site so I want the user can only send message to specific user or network admin. is it possible??

  • Jack Kitterhing
    • Code Norris

    Hi there @smart moms group,

    Hope you're well today and thanks for your question.

    Currently that isn't possible out of the box to restrict it to a certain username, I'll see if one of our developers @Hoang Ngo can provide any comments on how easy this would be to implement.

    Though the plugin isn't designed for this sort of functionality. :slight_smile:

    Thank you!

    Kind Regards
    Jack.

  • Hoang Ngo
    • Code Slayer

    Hi @smart moms group,

    I hope you are well today.

    We can achieve this by a small javascript code, this will hide the username text box, and add a new select box instead, which user can only chose the username from there.

    Please add this code to your theme functions.php or use mu-plugins

    add_action( 'admin_footer', 'restrict_messaging_users' );
    function restrict_messaging_users() {
    	$users = array(
    		'admin'
    	);
    	?>
    	<script type="text/javascript">
    		jQuery(document).ready(function ($) {
    			if ($('#message_to').size() > 0) {
    				$('#message_to').css('visibility', 'hidden');
    				var select = $('<select/>').attr({
    					'multiple': 'multiple',
    					'id'      : 'restrict_messaging_users_select'
    				});
    				var users_allow = <?php echo json_encode($users) ?>;
    				$.each(users_allow, function (i, v) {
    					select.append('<option value="' + v + '">' + v + '</option>');
    				})
    				$('#message_to').closest('td').prepend(select);
    			}
    			$('body').on('click','#restrict_messaging_users_select',function(){
    				$('#message_to').val($(this).val().join(' ,'));
    			})
    		})
    	</script>
    <?php
    }

    You will see the variable $users, this is where you define the username, to add more username, you can do like this

    $users = array(
    		'admin','username','another_user_name'
    	);

    If you have any issues please don't hesitate to let us know so we can assist

    Best Regards,
    Hoang

  • oliver_haslam
    • Design Lord, Child of Thor

    Hi

    I love the Messaging plugin but it doesn't quite do what I'd like.

    I'd like to stop 'subscriber' level users from creating new messages. I'd like them to be able to reply to any messages they receive but not initiate new messages.

    Can you help me with this please?

  • oliver_haslam
    • Design Lord, Child of Thor

    Hi Jack

    Thanks for your reply. I submitted the question already (sorry for the double posting, got a bit confused with help/support/forum areas here).

    I got a really useful reply to my question which does almost all I wanted - the only downside is it leaves the 'New Message' button visible to subscribers.
    See https://premium.wpmudev.org/forums/topic/how-to-stop-subscribers-from-creating-new-messages?replies=6#post-696091

    If you have another take on it I'd be great to hear :slight_smile:

    Thanks again.
    Cheers
    Oliver

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.