Creating roles programmatically: Difference between revisions
From MoodleDocs
Created page with "You may find that the default roles do not answer the needs of your plugin. In that case, you want to create a role programmatically. ==Setup== The first step is to create an in..." |
|||
| Line 2: | Line 2: | ||
==Setup== | ==Setup== | ||
We will use a plugin called myplugin. | |||
It is best to create capabilities for your plugin first as they will be used to create the role. You can also use default Moodle capabilities. For more information, please refer to [[Roles#Programming_Interface]] | |||
The first step is to create an install.php file in the db folder of your plugin. | The first step is to create an install.php file in the db folder of your plugin. | ||
<pre> | <pre>/mod/myplugin/db/install.php</pre> | ||
Revision as of 18:12, 1 March 2013
You may find that the default roles do not answer the needs of your plugin. In that case, you want to create a role programmatically.
Setup
We will use a plugin called myplugin.
It is best to create capabilities for your plugin first as they will be used to create the role. You can also use default Moodle capabilities. For more information, please refer to Roles#Programming_Interface The first step is to create an install.php file in the db folder of your plugin.
/mod/myplugin/db/install.php