Trying to get property 'id' of non-object

Trying to get property 'id' of non-object

by what what -
Number of replies: 4

Hi everyone,

Moodle 3.7.2

I am getting below errors with PHP occasionally, from all enrol options.
It happens only when the administrator is navigating through Administration Page.
All lines below will have "student->id" on these lines.


Anyone encountered this issue?


[25-Dec-2019 10:30:39 America/New_York] PHP Notice:  Trying to get property 'id' of non-object in /var/www/html/moodle/enrol/cohort/settings.php on line 39

[25-Dec-2019 10:30:39 America/New_York] PHP Notice:  Trying to get property 'id' of non-object in /var/www/html/moodle/enrol/database/settings.php on line 89

[25-Dec-2019 10:30:39 America/New_York] PHP Notice:  Trying to get property 'id' of non-object in /var/www/html/moodle/enrol/manual/settings.php on line 66

[25-Dec-2019 10:30:39 America/New_York] PHP Notice:  Trying to get property 'id' of non-object in /var/www/html/moodle/enrol/mnet/settings.php on line 39

[25-Dec-2019 10:30:39 America/New_York] PHP Notice:  Trying to get property 'id' of non-object in /var/www/html/moodle/enrol/paypal/settings.php on line 69

Average of ratings: -
In reply to what what

Re: Trying to get property 'id' of non-object

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

I think the Moodle site has the default role "Student" removed. Check Site administrationUsersDefine roles and see if it's there.

Role list

Some enrolment plugins use the student role as their default so when this is missing the errors listed will occur.

I think this is a bug, i.e. using a value as default that it's possible to delete, so I've reported MDL-67614.

I think it's a little obscure to delete the default roles. Do you know why this was done?

In reply to Leon Stringer

Re: Trying to get property 'id' of non-object

by Dorian C -
Thanks for replying Leon,

Student role is there.
In reply to Dorian C

Re: Trying to get property 'id' of non-object

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Maybe the student role doesn't have the archetype student.

From the Site administrationUsersDefine roles page, click edit (⚙) for "Student". On the "Editing role 'Student'" page what does the Role archetype field say? This should be the fourth field down.

Role archetype for Student

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Trying to get property 'id' of non-object

by Dorian C -
Thanks Leon, that seems to work!

Appreciate your help.