Changing the Divi Role Editor Defaults
The Divi Theme comes with a role editor that lets you control which user roles (administrator, editor, contributor, etc) can use which Divi features. By default, everyone has access to everything and you must explicitly disable any features you don't want accessed by particular user roles. Today I was looking for a way to programmatically restrict a module so that, by default, it would only be enabled for administrators.
It would be easy to do this if there was a suitable filter on the role editor settings, but as yet there isn't. Instead, I was able to do it by directly altering the option which stores the role editor settings. Here's an example of my approach, in this case setting the login module to be enabled for the administrator only:
Related Post: Adding PHP to the Divi Theme
The first time the code runs, it sets the named role setting to off for all but the administrator. It then records the roles it has affected, so that a) it doesn't change them in the future, and b) it can detect and set the default on any roles added in the future. By only modifying the value for a role once, it ensures that subsequent changes made by the administrator are not overwritten.
Want get more out of Divi?
Hundreds of new features for Divi
in one easy-to-use plugin