Need capability to restrict messaging from users of the same role

Hi, I'm planning on using your plugin for Teacher - Family communication in a Kinder, but I don't want families to be able to message other families. I see that in the capabilities addon there is an option to restrict by role, but it doesn't let me restrict messaging between users of the same role. I only want teachers to be able to message families and vice-versa. And the admin being able to message everyone.

Also, is there any way to restrict per user instead of only per role? I'd like to have only certain teachers messaging certain families.

Thank you, love your plugins.

  • Vaughan

    Hi alfredo,

    Hope you're well?

    I haven't tried this, but you would need to edit the plugin code for this.

    Possibly try the following;

    Open & edit the following file:

    /home/vaughan/Downloads/private-messaging/app/addons/capatibility.php

    Find the following on or around line 159:

    <?php if ($k != $key): ?>

    Replace with:

    <?php if ($k): ?>

    Now you should see in capabilities you can select that same role in the list.

    Hope this helps

  • Alfredo

    Thank you, that worked perfectly.

    Also, I found an error somewhere else. When I'm using the inbox shortcode, in the "Sent" tab, all messages show this error right before each message and after the "sent to", it doesn't show who the message was sent to and shows this instead:

    Notice: Trying to get property of non-object in /home/inspirationlab5e/public_html/wp-content/plugins/private-messaging/app/models/mm-message-model.php on line 87
    
    Notice: Trying to get property of non-object in /home/inspirationlab5e/public_html/wp-content/plugins/private-messaging/app/models/mm-message-model.php on line 87
    
    Notice: Trying to get property of non-object in /home/inspirationlab5e/public_html/wp-content/plugins/private-messaging/app/models/mm-message-model.php on line 92
  • Vaughan

    Hi Alfredo,

    I'm not seeing those errors. It could be the notices themselves that's causing the sent to issue.

    Could you try setting WP_DEBUG to false in your wp-config.php

    Then add the following 2 lines.

    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );

    This should hide the notices & instead write them to a file called debug.log in /wp-content instead.

    Hope this helps