Moodle User Management URLs

Some handy user management and search URLs, particularly if the site admin block is hidden.

User search

Note a %20=means a blank space, encoded to work in a URL.

user/index.php?id=1&search=
http://yourmoodle.com/user/index.php?id=1&search=fred
http://yourmoodle.com/user/index.php?id=1&search=Fred%20Jones

Create a new user

user/editadvanced.php?id=-1
http://yourmoodle.com/user/editadvanced.php?id=-1

Edit a user if you know their moodle internal id

user/editadvanced.php?id={moodle_user_id}
http://yourmoodle.com/user/editadvanced.php?id=16

Delete an existing user

This requires a session key (which is a godo thing!) so you need to do this once in the user edit area.

admin/user.php

If you don’t see a delete action for a user it usually means they are a site admin so you need to take them out of site admin first.

Assigning site administrators

admin/roles/admins.php
http://yourmoodle.com/admin/roles/admins.php

Assign site admins through the database

The following steps can be used to add your user as a siteadmin in the database if required.

Step 1: Find your moodle user ID

select id from mdl_user where username = '{username}';

Step 2: Get the list of current siteadmin IDs

select value from mdl_config where name = 'siteadmins';

This gives you a list of Moodle user ids in a list that are siteadmins. What you want to do is append your Moodle user ID to the end of the list (assuming it isn’t there already!).

Step 3: Add your moodle user id to the list

You can do this manually, simple add ‘,{your_moodle_userid}’ to the text or you can use a query like this:

select concat(value, ',', (select id from mdl_user where username = '{username}'))
from mdl_config
where name = 'siteadmins';

Step 4: Update the siteadmin list

The following SQL does the deed of updating the list of siteadmins so be very careful. Ues the results from step 3 to perform this update. If anything goes wrong use the results from step 2 to revert the changes.

update mdl_config
set value = '{list_of_siteadmins_with_your_moodle_userid}'
where name = 'siteadmins';