Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+6 votes
1.5k views
in Q2A Core by
Is there anyway to disable private messages between users but keep it enable for admin?

as admin i want to send private messages to my users and i don't want users to send private messages to each other.

It seems that disabling private message disables messages for admin also.
Q2A version: latest

2 Answers

+7 votes
by
selected by
 
Best answer
You can hack the core as follows:

in qa-include/pages/message.php

change this at line 52..

if ($handle === $fromhandle) {
// prevent users sending messages to themselves
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}

to this...

// prevent users sending messages to themselves or user is not equal to admin
if ($handle === $fromhandle || $fromhandle != 'admin user name goes here') {
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
by
Thanks alot its working...
Is it possible to hide "send private message" button for other users ? only admin should visible that button
by
edited by
Edit the following page...

qa-include/pages/user-profile.php

change this at line 393...

    // Private message link

    if (qa_opt('allow_private_messages') && isset($loginuserid) && $loginuserid != $userid && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting) {
        $qa_content['form_profile']['fields']['level']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array(
            '^1' => '<a href="' . qa_path_html('message/' . $handle) . '">',
            '^2' => '</a>',
        ));
    }

to this...

    //    Private message link
    // only display for admin
    if ( qa_get_logged_in_level() >= QA_USER_LEVEL_SUPER ) {
    if (qa_opt('allow_private_messages') && isset($loginuserid) && $loginuserid != $userid && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting) {
        $qa_content['form_profile']['fields']['level']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array(
            '^1' => '<a href="' . qa_path_html('message/' . $handle) . '">',
            '^2' => '</a>',
        ));
    }
        }
by
perfect it is working too. thanks..
by
No problem. Glad it is working for you.
by
Thank you for your help #bluegenel. I appreciate it. :)
by
No problem John. Glad to help.
0 votes
by

for QA 1.8.3;

in qa-include/pages/message.php 

change  this at line 150

if ($toaccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) {

to this

if (($toaccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && qa_get_logged_in_level() < QA_USER_LEVEL_SUPER) {

and

in qa-include/pages/user-profile.php  

change this at line 791

if (qa_opt('allow_private_messages') && isset($loginuserid) && $loginuserid != $userid && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting) {

to this

if ((qa_opt('allow_private_messages') && isset($loginuserid) && $loginuserid != $userid && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting) || qa_get_logged_in_level() >= QA_USER_LEVEL_SUPER) {

...