I'm trying to create a custom module for payment. When installed, the module automatically adds two fields to the 'Article' content type.

I have 'enable/disable checkbox' in the form:

Enable: Should mean that people on my live website can use it

Disable: Should mean that no-one can use it (I don't want to remove the variables or the fields in the article content typ, I just want to hide everything in relation with the module)

Is there any hook or any thing that can do that? Turn the module off?

  • Not sure what you are asking, but do you mean you want to turn your module off from inside its own code? Jun 3, 2013 at 16:09
  • @AlfredArmstrong yes dudde ^_^ Jun 3, 2013 at 16:30
  • When using the standard admin UI, once you disable your module, Drupal will never invoke it, which means any modifications to forms, like what you are describing here, will never take place. Why would you go through the extra trouble of duplicating this logic in your module, which I might add, will never have any effect, again, if the module is disabled?
    – 9ee1
    Jun 3, 2013 at 16:34
  • 2
    I think you need to explain a little more about why you want to do this. You'll probably get a better answer if you describe the result you are trying to achieve rather than how you want to do it. Jun 3, 2013 at 16:42
  • It doesn't sound like you want to enable/disable the module, as that would negate the point in writing it in the first place. It sounds like you just want the option to disable the two fields you have created whilst keeping their data - is this correct?
    – Chapabu
    Jun 3, 2013 at 20:42

1 Answer 1


You should try module_disable(array) function. Here is the documentation for it. Module Disable Programmatically

You should first check its existence by module_exists and you can also have a look at drupal_uninstall_modules.

I hope this will help you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.