Snippet · Mecha CMS

Code snippet collection for developers.

State Hooks

Author: Taufik Nurrohman · 573 Views

Tweet

Force some values to the default states values.

There will be a time when you want to force some configuration data of the extension and plugin to be specific to your custom shield. Here is an example on how to force the comment captcha type to text with black background and blue color using a hook:

Hook::set('plugin.state.comment-captcha', function($lot) {
    $lot['type'] = 'text';
    $lot['types']['text'][0] = '000';
    $lot['types']['text'][1] = '00f';
    return $lot;
});

Example for extension:

Hook::set('extend.state.minify', function($lot) { … });

Example for shield:

Hook::set('shield.state.document', function($lot) { … });

1 Comment

  • Alexander Liebrecht

    Hi Tovic and many thanks for the very useful hook. I have just tried with me and it works. So the auto spam bots have no chance to get through :-)