I developed a custom simple module for Divi builder. It shows correctly in the backend and frontend editor.
The problem is that it won’t save at all in the backend or frontend editor. When I place it into the backend editor and save the post, then it will lost after reloading the backend editor!
Here is my module class:
class My_Custom_Module extends ET_Builder_Module
{
public function init()
{
$this->name = __('My Custom Module', 'wpl');
$this->slug = 'CUSTOM_SLUG';
}
}
new My_Custom_Module();
I followed this article https://jonathanbossenger.com/building-your-own-divi-builder-modules/ and How to create custom Divi module? and some other articles that I found by Google.
I already tried to put some fields in get_fields function but it didn’t help too.
Also to make sure, it’s not a conflict, I disabled all other plugins but it didn’t fix so it’s not related to a conflict.
2
Answers
I finally found the problem myself and I'm sharing it here to help others if they face a same problem.
The simple module in the question doesn't save because its slug, which is missing the
et_pb_
prefix. It works fine when I change$this->slug = 'custom_module'
to$this->slug = 'et_pb_custom_module'
.I didn't see this rule in their documentation but I hope they mentioned it somewhere.
Here is the working code for a simple Divi custom module:
That shouln’t be happening. There might be a conflict caused by other plugins in wordpress. What I would do is do a fresh install of wordpress, apply Divi theme, try to save module. If it does save. Then you can isolate the problem and know which plugin is causing the issue by installing the plugins back in one by one.