General developer forum

 
 
Picture of Ali Rajabpour Sanati
force users to complete custom profile fileds when login
 

hello everybody,

i have created some custom profile fileds, but i don't know how to make all registered users to complete the fields as soon as they log in to moodle...

thank you in advanced

 
Average of ratings: -
Picture of Rob Bright
Re: force users to complete custom profile fileds when login
 

If you are logged in as admin, go to: Site administration -> Users -> Accounts -> User Profile Fields -> Create a new profile category and choose what kind of input the users should add, either a checkbox, date/time, menu of choices, text area or text input. Then when you scroll down, there is an option "Is this field required?". Change this to yes, then users must enter this data when they register on the site.

 
Average of ratings: -
Picture of Ali Rajabpour Sanati
Re: force users to complete custom profile fileds when login
 

thank you for ur sharp reply, but i want users which are already registered complete the fields...!

 
Average of ratings: -
Picture of Ali Rajabpour Sanati
Re: force users to complete custom profile fileds when login
 

Please somebody help mesad

 
Average of ratings: -
Picture of Ali Rajabpour Sanati
Re: force users to complete custom profile fileds when login
 

guys please help me change the moodle required fileds to force all already registred users to complete custom profile fileds...

 
Average of ratings: -
Picture of Mr. Marc
Re: force users to complete custom profile fileds when login
 

is there a way to force all users to have a certain student profile picture and instructors to have a different one?

 
Average of ratings: -
Picture of Michael E
Re: force users to complete custom profile fileds when login
Group Testers

Ali,

I'm wondering if you ever found a solution for that. I would like to accomplish the same thing.

 

Thanks,

Michael

 
Average of ratings: -
Picture of Michael E
Re: force users to complete custom profile fileds when login
Group Testers

I just found the answer myself.

    1. Open the file lib/moodlelib.php
    2. Search for: function user_not_fully_set_up($user) {(approx. line 3383)
    The complete function looks like this:
    function user_not_fully_set_up($user) {
        if (isguestuser($user)) {
            return false;
        }
        return (empty($user->firstname) or empty($user->lastname) or empty($user->email) or over_bounce_threshold($user));
    }
    3. Edit the return string according to your needs. Use the shortname of the field you want to force users to fill in. The correct usage is: empty($user->profile['short_fieldname'])
    If the fieldname for example is managersemail (from the Face-to-Face mod), change the return string to:

return (empty($user->firstname) or empty($user->lastname) or empty($user->email) or empty($user->profile['managersemail']) or over_bounce_threshold($user));

Hope that helps!

 
Average of ratings:Useful (1)
Picture of David Hempy
Re: force users to complete custom profile fileds when login
 

Thank you, Michael!  I just implemented this on our 2.5 server

I added a permissions check to only require the extra fields from students (not admins, teachers, etc.).  That part kinda works, but has issues since students are difficult to detect outside of a course.  I'm going to tinker with it some more later, but here's a start if anyone else wants to pursue it.

    return (empty($user->firstname) or empty($user->lastname) or empty($user->email) or over_bounce_threshold($user)
       or (
           (    empty($user->profile['BirthMonth'])
             or empty($user->profile['BirthDate'])
             or empty($user->profile['BirthYear'])  
           ) and !has_capability('report/courseoverview:view', context_system::instance())  // Allows teacher to avoid required birthdate.
       )       
    );

 
Average of ratings: -
Ben Ellis - chilled ;)
Re: force users to complete custom profile fileds when login
 

Maybe we should ask for it as a new feature in tracker as I find myself facing the same issue.  

I am against hacking Moodle core code so I am intending to develop a plugin e.g. block that will direct the user to providing the information though I doubt I could force them to provide the info.  If anyone can think of a way to, I will gladly use listen.







 
Average of ratings: -