[Resolved] define( 'GENERATE_HOOKS_DISALLOW_PHP', true );

Home Forums Support [Resolved] define( 'GENERATE_HOOKS_DISALLOW_PHP', true );

Home Forums Support define( 'GENERATE_HOOKS_DISALLOW_PHP', true );

Viewing 15 posts - 1 through 15 (of 36 total)
  • Author
    Posts
  • #337060
    Gideon

    Hi,

    Since updating GP I am getting this message:

    DISALLOW_FILE_EDIT is defined. You should also disallow PHP execution in GP Hooks.

    I found te article stating that I should add the following to GP Hooks:
    define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true );

    Do I need to place this in a specific section?

    It looks like it’s not working as I still get the message.

    Thanks!

    #337071
    Leo
    Staff
    Customer Support

    Hi there,

    Try adding that line using Code Snippets: https://docs.generatepress.com/article/adding-php/#code-snippets

    #337100
    Gideon

    Thanks for your reply Leo!

    I am still getting the message though…

    #337101
    Leo
    Staff
    Customer Support

    Hmm just tried it and it worked for me.

    Can you make sure to click Save and Activate on the snippet?

    #337113
    Tom
    Lead Developer
    Lead Developer

    You can also add it to your wp-config.php file, which is where DISALLOW_FILE_EDIT is usually defined.

    That being set, it should work anywhere, including Code Snippets.

    #337115
    Gideon

    That’s weird as I did save and activate the code snippet…
    I also added it to several sections within GP Hooks before adding the code snippet.

    #337116
    Tom
    Lead Developer
    Lead Developer

    It won’t work in GP Hooks, but will in Code Snippets, child theme functions.php or wp-config.php.

    Is it still not working with the snippet activated?

    #337122
    Gideon

    That’s correct

    I have added this to the code snippet:

    define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true );

    Also saved and activated it

    It should run everywhere (selected for the code snippet)

    However, still getting the message

    #337151
    Tom
    Lead Developer
    Lead Developer

    You may need to add it to your wp-config.php file then.

    Or try this:

    add_action( 'after_setup_theme', 'tu_disable_php_in_hooks' );
    function tu_disable_php_in_hooks() {
        define( 'GENERATE_HOOKS_DISALLOW_PHP', true );
    }
    #337242
    Luca

    Hey, Tom.

    Sorry to “hijack” another user’s thread. I just wanted to mention that whilst such a warning makes sense, IMHO it should have probably been wrapped within an “if(!current_user_can(‘manage_options’))” as this way is otherwise shown to all users including subscribers and editors (let alone “customers” in a WooCommerce shop, how much confidence does it inspire to have a security warning you probably don’t understand popping up?) and it just pollutes their dashboard.

    My 2 cents.

    Keep up the good work!

    Cheers,
    Luca

    #337248
    Tom
    Lead Developer
    Lead Developer

    Interesting point. The notice only displays in the Dashboard, which is usually reserved for admins, editors etc.. not subscribers. I’ll absolutely add a check in there – thanks for the heads up!

    #337611
    Gideon

    Ok, adding it to the wp-config.php file did do the job.

    Thanks

    #337702
    Tom
    Lead Developer
    Lead Developer

    Awesome 🙂

    #340964
    Frances

    Hi you guys, I hope it’s ok I’m adding a comment to this support topic!

    I followed your instructions to add the following code to the “code snippet” plugin. I then saved/activated after checking to be sure ‘run snippet everywhere’ is checked.

    When I return to the dashboard the message is gone. However I now have the following characters appearing at the beginning of each page:

    ‘,’
    ‘); ?>

    Quite mysterious!

    When I delete the snippet the message comes back and the mysterious characters disappear.

    Am I missing a step? Was I supposed to also do something in GP Hooks? (I haven’t)

    If I need to add this code to the WP config file, where do I paste it? (sorry – totally green on this stuff!)

    add_action( ‘after_setup_theme’, ‘tu_disable_php_in_hooks’ );
    function tu_disable_php_in_hooks() {
    define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true );
    }

    and then do I then delete the code snippet?

    Thanks so much for illuminating me. I appreciate your help!

    Cheers,
    Frances

    #340965
    Leo
    Staff
    Customer Support

    Do you have anything added in the GP hooks module?

    If not can you link us to the page where this is happening? Thanks!

Viewing 15 posts - 1 through 15 (of 36 total)
  • You must be logged in to reply to this topic.