is there any option in moodle php to take username value in to variable ?
I just wanna take username in to $myUser when the form loading.
$mform->addElement('text', 'username', get_string('forumname', 'forum'), $attributes);
Reference:- http://docs.moodle.org/dev/lib/formslib.php_Form_Definition#addElement
From outside of your form:
In rare cases where this isn't possible, you can, instead, use customdata to pass it in:
Then, within your form: