Programmatically Set Default Text Editor I have a customized module that requires tinyMCE as a library.



After module installation, I still have to set my text editor in the image above. It was found in the admin/config/content/wysiwyg.

How will I programatically set tinyMCE as a default text editor right after module installation?
Below code is used in wysiwyg_profile_form_submit() at wysiwyg.admin.inc. You can make use of it.

// Insert new profile data.
db_merge('wysiwyg')
  -&gt;key(array('format' =&gt; $format))
  -&gt;fields(array(
    'editor' =&gt; $editor,
    'settings' =&gt; serialize($values),
  ))
  -&gt;execute();
wysiwyg_profile_cache_clear();


Another approach is using drupal_form_submit() to submit its settings form programmatically. But it would be more compliated.

Also, before settings the profile, you need to check if tinymce is existing.

if (wysiwyg_get_editor('tinymce')) {

  // set profile.

}