{"action":"created","issue":{"url":"https://api.github.com/repos/cannod/moodle-drupalservices/issues/75","repository_url":"https://api.github.com/repos/cannod/moodle-drupalservices","labels_url":"https://api.github.com/repos/cannod/moodle-drupalservices/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/cannod/moodle-drupalservices/issues/75/comments","events_url":"https://api.github.com/repos/cannod/moodle-drupalservices/issues/75/events","html_url":"https://github.com/cannod/moodle-drupalservices/issues/75","id":170179328,"number":75,"title":"moodle not creating user before first sign in, when new user is created in drupal ","user":{"login":"deepsimran","id":16906274,"avatar_url":"https://avatars.githubusercontent.com/u/16906274?v=3","gravatar_id":"","url":"https://api.github.com/users/deepsimran","html_url":"https://github.com/deepsimran","followers_url":"https://api.github.com/users/deepsimran/followers","following_url":"https://api.github.com/users/deepsimran/following{/other_user}","gists_url":"https://api.github.com/users/deepsimran/gists{/gist_id}","starred_url":"https://api.github.com/users/deepsimran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deepsimran/subscriptions","organizations_url":"https://api.github.com/users/deepsimran/orgs","repos_url":"https://api.github.com/users/deepsimran/repos","events_url":"https://api.github.com/users/deepsimran/events{/privacy}","received_events_url":"https://api.github.com/users/deepsimran/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-08-09T14:23:02Z","updated_at":"2016-08-10T19:56:25Z","closed_at":null,"body":"This plugin is working well and serves everything i need, instead of one thing.\r\n\r\nI am using [commerce moodle integration ](https://www.drupal.org/project/commerce_moodle) and [moodle connector ](https://www.drupal.org/project/moodle_connector) modules with this plugin for the auto enrollment in the courses in moodle.\r\n\r\n Its working as a charm for the existing users, but when a new user creates a user account on the drupal side, buy a course and then goes to the moodle and found that it is not enrolled in the course which is quite obvious as user is not present in the moodle database before his first sign-in.\r\n\r\nBut when the same user goes to the drupal side and buy a course again, this time he will be automatically enrolled in the course as same user is in the database.\r\n\r\nDoes somebody have some sort of solution to my problem?  \r\nI like the functionality of this plugin as it offers SSO. But i really want to solve this problem. Anyone knows how to solve this issue please share your suggestions.\r\n\r\nThanks in Advance.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/cannod/moodle-drupalservices/issues/comments/238984757","html_url":"https://github.com/cannod/moodle-drupalservices/issues/75#issuecomment-238984757","issue_url":"https://api.github.com/repos/cannod/moodle-drupalservices/issues/75","id":238984757,"user":{"login":"goose2000","id":2395298,"avatar_url":"https://avatars.githubusercontent.com/u/2395298?v=3","gravatar_id":"","url":"https://api.github.com/users/goose2000","html_url":"https://github.com/goose2000","followers_url":"https://api.github.com/users/goose2000/followers","following_url":"https://api.github.com/users/goose2000/following{/other_user}","gists_url":"https://api.github.com/users/goose2000/gists{/gist_id}","starred_url":"https://api.github.com/users/goose2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goose2000/subscriptions","organizations_url":"https://api.github.com/users/goose2000/orgs","repos_url":"https://api.github.com/users/goose2000/repos","events_url":"https://api.github.com/users/goose2000/events{/privacy}","received_events_url":"https://api.github.com/users/goose2000/received_events","type":"User","site_admin":false},"created_at":"2016-08-10T19:56:25Z","updated_at":"2016-08-10T19:56:25Z","body":"Oh, we could leverage the moodle connector module too, everything we need is there for moodle connection.\r\n\r\n@deepsimran \r\n\r\nYou will have to edit these for you DB names and tables. TEST somewhere not production. If you are not comfortable with MySQL, this may not be advisable solution.\r\n\r\nHere is AFTER INSERT trigger\r\n\r\n`CREATE DEFINER=`root`@`%` TRIGGER `moodle_user_insert` AFTER INSERT ON `users` FOR EACH ROW BEGIN\r\nINSERT INTO zmdl_user(auth, confirmed, mnethostid, username, idnumber, email, country, lang)\r\nVALUES(\"drupalservices\", \"1\", \"1\", new.name, new.uid, new.mail, \"US\", \"en_us\");\r\nEND`\r\n\r\nAFTER UPDATE: // updated only the email and username\r\n\r\n`CREATE DEFINER=`root`@`%` TRIGGER `moodle_user_update_email` AFTER UPDATE ON `users` FOR EACH ROW BEGIN\r\n   UPDATE zmdl_user\r\n    SET username = new.name, email = new.mail\r\nWHERE old.uid = idnumber;\r\nEND`\r\n\r\nBEFORE DELETE  // because after they're gone, we can't find them... \r\n\r\n`CREATE DEFINER=`root`@`%` TRIGGER `moodle_user_delete` BEFORE DELETE ON `dp7_users` FOR EACH ROW BEGIN\r\nDELETE FROM mdl_user WHERE OLD.uid = idnumber;\r\nEND`\r\n"}}
{"actor":{"display_login":"goose2000"}}