Use module_implements_alter() to force running last

Created on 15 February 2024, 4 months ago
Updated 11 March 2024, 3 months ago

First, this plugin is a thing of beauty, and turns out to be exactly what I needed.

One of my uses is to override the "Content language and translation" form present at admin/config/regional/content-language when translation is enabled. It turns out that when content moderation is also enabled, the "moderation status" checkbox, while it appears to be selectable, doesn't "take" when you save the settings.

I tracked this down to core content moderation not taking base field overrides into account.

When implementing my form alter, I discovered that it was firing well before the actual content moderation module's own form alter, so my alteration was being ignored. I corrected this by adding this snippet to my `.module`:

function my_module_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'form_alter') {
    $group = $implementations['pluginformalter'];
    unset($implementations['pluginformalter']);
    $implementations['pluginformalter'] = $group;
  }
}

This forces your plugin to run its alters after all others, and made my changes work.

I'm not sure if this is something you might want to document, or even add to your code. Just putting it here for info.

✨ Feature request
Status

Fixed

Version

1.6

Component

Documentation

Created by

🇺🇸United States datawench

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024