0

i have this define

define('DISALLOW_FILE_MODS', true);

but i need to execute a function with the define set to false. is it possible and in case how?

  • That's done very early in the load process so I'd guess not, depending on what you're trying to do. What are you trying to do? However you can always override this value later using the file_mod_allowed hook. – Rup Feb 5 at 13:20
  • i need to get the data of what wp needs updates (plugin, theme....) but i can't with that. – DevBeppe Feb 5 at 13:25
  • 1
    Can't you? At first glance wp_update_themes() doesn't check wp_is_file_mod_allowed() – Rup Feb 5 at 13:32
  • i'm reading about file_mod_allowed() but I'm confused about how use it. i have a daily cronjob on a function who use $updates = wp_get_update_data(); so how can i use my_function with file_mod_allowed hook? – DevBeppe Feb 5 at 14:12
  • Hmm, wp_get_update_data calls current_user_can to check if it can return updates. Yes, the capabilities are filtered by wp_is_file_mod_allowed. I'm not sure how that works from cron jobs - what counts as the current user for cron? (Is this the WordPress cron job or something externally triggered?) It might be simpler to avoid calling wp_get_update_data if you can get the numbers from somewhere else, or copy the code to use in your cron job and edit out the permissions checks, but I don't know the correct way to do this. – Rup Feb 5 at 14:27
0

Is not possible to redefine a constant. Once a constant is defined, it can never be changed or undefined (From PHP Manual).

|improve this answer|||||
0

This is a constant, not a variable. The constants are not to change. You can not change it.

You should use a true variable instead.

You can read this: https://www.php.net/manual/en/function.define.php

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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