Hi,
I've been reading about the new roles & permissions stuff in 1.7, but I just don't quite 'get' what I'm actually meant to replace an isguest() function call with. The roles page (http://docs.moodle.org/en/Roles#Guests) says there will be still be a guest account, but with "no default role at site level" - but with the new functions (has_capability etc) what do I use to test if they have no role?
I know that just leaving isguest() will work for now - but I'd like to try and avoid using deprecated functions!
TIA,
Alex
Interestingly in the current code, the roles stuff is commented out in the isguest() function and it simply checks if the username (of the current user) is 'guest'. So, it seems the function won't work if you assign anybody other than 'guest' with guest rights.
isguest() is indeed deprecated and there for backward compatibility only.
A lot of new changes regarding all this will hit CVS soon, but basically even people who are not logged in will have a 'role' that has_capability can test against. By default it's the guest role, but through $CFG->notloggedinrole you can change it to something else if you choose.
The short answer is: use has_capability() all the time.
A lot of new changes regarding all this will hit CVS soon, but basically even people who are not logged in will have a 'role' that has_capability can test against. By default it's the guest role, but through $CFG->notloggedinrole you can change it to something else if you choose.
The short answer is: use has_capability() all the time.