• Code snippet activation

    Posted by Johnny Andrade  on June 6, 2025 at 8:00 pm

    Hi Hasan

    Following WordPress SAAS 2.0 Course Adding a Basic Captcha


    I created the 2 snippets where I copied and pasted the codes you provided

    A strange thing happened when I was trying to activate them.

    It allows only 1 on them to activate at the same time, the other one when trying to active, give me an error.


    please help


    Johnny

    Hasan replied 3 weeks ago 2 Members · 3 Replies
  • 3 Replies
  • Hasan

    Administrator
    June 6, 2025 at 8:33 pm

    It happens sometime, is there any snippets with similar function names?

    Refresh the page, and try enabling again.

  • Johnny Andrade

    Member
    June 6, 2025 at 10:38 pm

    Hi Hasan,

    Following your training, I asked ChatGPT and got the conflict resolved—thanks!

    This is ChatGPT’s reply:

    The reason you cannot activate both snippets at the same time in WordPress is because they define the same functions and hooks, which leads to function name conflicts and duplicate REST route registrations.

    🔍 What’s the conflict?
    Both snippets define the same function names:

    • generate_simple_captcha()

    • verify_captcha()

    • generate_in_json()

    And both register the same REST route:

    register_rest_route(‘api/v1’, ‘/idea-generator’, […])

    This causes a “function already declared” or “route already registered” conflict when WordPress tries to activate the second snippet

    • This reply was modified 3 weeks ago by  Hasan.
  • Hasan

    Administrator
    June 8, 2025 at 8:47 am

    thanks for sharing, yeah thats exactly what I mentioned, same functions with same names, it causes a conflict.

Log in to reply.