0

I need to change a user's role to admin in a Moodle installation (I'm not knowledgeable in Moodle whatsoever), since I've got not access to the backoffice or admin tools. I can only access the database.

I've been looking at the several tables and their documentation but I can't seem to find which table has the user permissions?

Sasha Fonseca
  • 2,257
  • 23
  • 41

2 Answers2

0

The site admin role has permission to do anything in Moodle, so use with caution.

You will need to know the user id first - so retrieve the id from this table

SELECT *
FROM mdl_user

Then add the id to the value column here

SELECT *
FROM mdl_config
WHERE name = 'siteadmins'

For example

UPDATE mdl_config
SET value = value || ',3'
WHERE name = 'siteadmins'

You will probably need to log out and back in again for this to take affect.

This is only works for site admins. For other roles you will need to log in as an admin and go to site admin -> users -> permissions

Russell England
  • 9,436
  • 1
  • 27
  • 41
0

Just add this line in config.php

$CFG->siteadmins = 2;