I have a file containing all the constants used in the plugin. For example, I have a variable in one of my file define('APPOINTMENTS_DEFAULT_ENABLE_PAYPAL', 1);

I have a checkbox in admin area where user can enable or disable the paypal feature. This is the checkbox code: <input type="checkbox" name="enable_paypal" size="40" value=""/>

Issue: Can anybody please tell me how can I write code to modify the define() so that when checkbox is clicked then make the value to 1 and otherwise value should be 0?

  • 4
    a constant is… constant. you can't modify it once it's been defined.
    – Milo
    Commented Dec 6, 2013 at 4:23
  • sir when user changes there options i need to update that in my code. and by the name "constant" i mean after user changes the option then until he changes it again the value should remain same.
    – Zammuuz
    Commented Dec 6, 2013 at 4:40
  • 1
    this question is not related to wordpress and yes, a constant by definition can not be changed, that is why it is a constant Commented Dec 6, 2013 at 5:36
  • @nikki : constant is a particular type of data in PHP. You should not use the word "constant" to refer to anything but that particular type of data. It will cause confusion.
    – s_ha_dum
    Commented Dec 7, 2013 at 15:16

1 Answer 1


You can't alter a constant once it is defined. That is how PHP works. Don't fight it.

The good news is that you should not be using a constant at all. Use options.

// get your value
// the second parameter is the default
$enable_paypal = get_option('enable_paypal',true);

// set your value based on, I assume, a form of some kind




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.