How to change user data

How to change user data

by Robert Narewski -
Number of replies: 1

Hello,

Quick question:

how to change data fields in /user/editlib.php?

When I try change, user field 'email':

$user->email = "test@gmail.com";

it works, i can save it

but I want to get field value from 'username'

and put it into 'email' field


(My users names are always email)



Average of ratings: -
In reply to Robert Narewski

Re: How to change user data

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi,

it's probably NOT the best way (I mean it's a bad way...).

But for a quick change you can goto the file

\user\editadvanced_form.php

in the validation function you can replace the line 256 or near... (public function validation($usernew, $files) )

Replace

$usernew->username = trim($usernew->username);

by

$usernew->username = trim($usernew->email);


hope it's work !

Dominique.

Average of ratings: Useful (1)