diff --git a/auth/ldap/lib.php b/auth/ldap/lib.php index 212b977f6e1..6789587f9a6 100644 --- a/auth/ldap/lib.php +++ b/auth/ldap/lib.php @@ -368,7 +368,7 @@ function auth_iscreator($username=0) { } if ((! $CFG->ldap_creators) OR (! $CFG->ldap_memberattribute)) { - return false; + return null; } return auth_ldap_isgroupmember($username, $CFG->ldap_creators); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index f76b0567673..63c83390a15 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -949,20 +949,23 @@ function authenticate_user_login($username, $password) { } if (function_exists('auth_iscreator')) { // Check if the user is a creator - if (auth_iscreator($username)) { - if (! record_exists("user_coursecreators", "userid", $user->id)) { - $cdata->userid = $user->id; - if (! insert_record("user_coursecreators", $cdata)) { - error("Cannot add user to course creators."); + $useriscreator=auth_iscreator($username); + if(!is_null($useriscreator)) { + if ($useriscreator) { + if (! record_exists("user_coursecreators", "userid", $user->id)) { + $cdata->userid = $user->id; + if (! insert_record("user_coursecreators", $cdata)) { + error("Cannot add user to course creators."); + } + } + } else { + if ( record_exists("user_coursecreators", "userid", $user->id)) { + if (! delete_records("user_coursecreators", "userid", $user->id)) { + error("Cannot remove user from course creators."); + } } } - } else { - if ( record_exists("user_coursecreators", "userid", $user->id)) { - if (! delete_records("user_coursecreators", "userid", $user->id)) { - error("Cannot remove user from course creators."); - } - } - } + } } return $user;