• Resolved urgul

    (@urgul)


    Hi,

    after updating Code Snippets to the latest version (free) I can’t save my snippets. There’s an error: Could not create snippet. Request failed with status code 406

    I can’t even save my old snippets, which previously worked (save) without any issues.

    Please help.

    The snippet I can’t save:

    function apply_custom_css_for_specific_url() {
    if (is_user_logged_in() && strpos($_SERVER[‘REQUEST_URI’], ‘/moje-konto/edit-account/’) !== false) {
    echo ‘my custom CSS’;
    }
    }

    add_action(‘wp_head’, ‘apply_custom_css_for_specific_url’);

    There’s following error in the console when I try to save the snippet: POST https://mydomain.com/wp-json/code-snippets/v1/snippets/34? 406 (Not Acceptable)

    WordPress 6.5.2, PHP 8.1

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi @urgul,

    Can I ask as to whether you have introduced any new security software? Either something on the server-side like CloudFlare or modsec, or a security plugin? It seems like something on your site is blocking the request.

    Secondly, have you tried adding a new snippet with an empty code area, to see if that works?

    Thread Starter urgul

    (@urgul)

    The problem has been solved. Modsec was blocking the request.

    • This reply was modified 6 months ago by urgul.
    Plugin Author Shea Bunge

    (@bungeshea)

    Thank you for the update!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Could not create snippet. Request failed with status code 406’ is closed to new replies.