Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
489 views
in Q2A Core by

I disabled users to change email and username. Now I want a system that will disable users to change Full Name.

Related question:

Full Name can't change before 60 days ?

Q2A version: 1.8.6 (Latest)

1 Answer

0 votes
by
edited by

Updated:

In qa-include/pages/account.php of version 1.8.6:

After this block:
foreach ($userfields as $userfield)
        $inprofile[$userfield['fieldid']] = qa_post_text('field_' . $userfield['fieldid']);

Add this line:
$inprofile[$userfields['name']['fieldid']] = $userprofile['name'];

Around line#417 

change this:
'type' => $isblocked ? 'static' : 'text'

To:
'type' => ($label == 'Full name:'? 'static': ($isblocked ? 'static' : 'text')),

Explanation:

qa_user_userfield_label() procedure is used to get 'Full name' and other fields, including custom fields created on 'Users' admin page.  In the above code, I'm changing the type of the field named 'Full name:' from 'text' to 'static'.  Note the ':' there, which is added at line 408.  Making the field 'static' will prevent it from being edited.

The first change (adding a new line of code) is to fetch the current 'Full name' and set it in the post action.  Otherwise, the 'Full name' gets cleared.  Another way to do this, I think, is to remove the feildid of 1 so that the Full name is not updated at all.

For external users, I wish it was easier to prevent changing fields like Username, Email and Full Name.  Maybe Location as well.

by
FYI, I also commented the 'Change password form' following the above change.  That prevented the users from modifying the password.  This was done because for external users, change password will not work anyways.
...