Diasbling editing profile?

Diasbling editing profile?

by Genner Cerna -
Number of replies: 8
How do I disable editing or changing the possible data using external database where data are provided by the admin.
Average of ratings: -
In reply to Genner Cerna

Re: Diasbling editing profile?

by Przemyslaw Stencel -

There's no way to achieve this other than tampering with the code. You can block the possibility of changing the profiles by editing the user/edit.html file.

For example, if you would like to block the possibility of changing the first name, locate the following piece of code (lines 56-57):
<td><input type="text" name="firstname" size="30" maxlength="20" value="<?php p($user->firstname) ?>">
<?php if (isset($err["firstname"])) formerr($err["firstname"]); ?>

and change it to:
<td><?php p($user->firstname) ?>

Other fields can be blocked in the same way.

Hope this helps,
Przemek

In reply to Przemyslaw Stencel

Re: Diasbling editing profile?

by Genner Cerna -
But the problem with that when you try to click the update bottom data in the said field will be lost.
In reply to Genner Cerna

Re: Diasbling editing profile?

by Peter Jansen -
Can anyone follow up on this?

I would like to disable the "Edit Profile" since I do not wish my students having funky names at the end of each day.

Thank You
In reply to Peter Jansen

Re: Diasbling editing profile?

by Maria Oleynik -
Peter,
Hi!

I am in the same situation and I am trying to find the answer to it. Did you manage to figure out how to disable the Edit Profile Option and leave only Change Password? I tried to do via Authentication, but it did not work.

Regards,
Maria
In reply to Maria Oleynik

Re: Diasbling editing profile?

by Ken Shino -

if you look at the file view.php in /user/

At lines 124 to 128.

"

        echo "<p><form action=\"$wwwroot/user/edit.php\" method=\"get\">";
        echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />";
        echo "<input type=\"hidden\" name=\"course\" value=\"$course->id\" />";
        echo "<input type=\"submit\" value=\"".get_string("editmyprofile")."\" />";
        echo "</form></p>";

"

If you look at this is where it draws the button when u click on ur name and the edit profile shows.

if you want  you could put:

"

 if (isadmin()) {

        echo "<p><form action=\"$wwwroot/user/edit.php\" method=\"get\">";
        echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />";
        echo "<input type=\"hidden\" name=\"course\" value=\"$course->id\" />";
        echo "<input type=\"submit\" value=\"".get_string("editmyprofile")."\" />";
        echo "</form></p>";

}

"

This will basically only show the edit button form to the admins of this application other users will then not see their edit button.

This is a quick way to do it. Or you could also just simply comment these lines so the form wont show the button at all.

In reply to Ken Shino

Re: Disabling editing profile?

by Jan Dierckx -

Ken's solution will hide the link to the user profile page. But this will not completely prevent students changing their profile because there are other ways of accessing the same page.

(Hiding links is not the way to prevent students accessing pages. I have noticed that some students are very keen on finding pages that have no visible links to them. It is mostly these students of course who also like to change names smile )

Moodle 1.5 -- the beginning of this discussion daes from more than 1 year ago! -- now includes the ability to lock fields in the userprofile.That way you can make sure students don't change names on every (bad) occasion.

See this discussion

In reply to Jan Dierckx

Re: Disabling editing profile?

by Genner Cerna -
Use external database for this problem, you could lock some field. see authenticating external database.
In reply to Genner Cerna

Re: Diasbling editing profile?

by Ken Shino -

simply do

<td><input type="hidden" name="firstname" size="30" maxlength="20" value="<?php p($user->firstname) ?>"><?php p($user->firstname) ?></td>

this basically will create a hidden value field with firstname which the script should still get and show the first name as a label text and not an input textbox