• Resolved Josh Journey

    (@ljosh)


    Howdy, I decided to try out allowing more answers but am stuck. When adding HDQ_MAX_ANSWERS to my themes functions.php via the following code
    define(‘HDQ_MAX_ANSWERS’, 10);

    This produces the following error:
    Warning: Constant HDQ_MAX_ANSWERS already defined in /home/site/wp-content/themes/twentytwentyfour/functions.php on line 49

    Of course I make sure the code is not within any blocks and has a line break above and below. I’ve added filters for various plugins with great success. Looking into this further I decided to try:
    if (!defined(‘HDQ_MAX_ANSWERS’)) define(‘HDQ_MAX_ANSWERS’, 44);

    But this literally does nothing (answers remain to show the default 10). Meaning it would seem HDQ_MAX_ANSWERS is defined before loading functions.php? Does this happen on your end? Is more code needed to clear the original?

    Warm regards,
    Josh

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    HDQ_MAX_ANSWERS is not a filter, it’s a definition. The reason it does nothing when you wrap it in the if statement is because as the warning you saw, it is already defined.

    The problem you have is that you are loading the definition too late. The definition needs to be loaded BEFORE plugins load.

    Something you can do to force it to load before plugins is to add the definition to the wp-config.php file, as WP always loads those variables before anything else.

    Thread Starter Josh Journey

    (@ljosh)

    Thank you Dylan! That added 44 possible answers. ?? Looking back at documentation it literally states:

    HDQ_MAX_ANSWERS? – This is a definition that sets the max number of answers per question.By default, this is 10, but you can set define('HDQ_MAX_ANSWERS', 10); to whatever number you want in your theme’s functions.php file.

    https://hdplugins.com/learn/documentation/hd-quiz-documentation/#secret-settings

    I suggest changing the last part of the above quote to mention wp-config.php instead of functions.php. I’ll write a review when they are allowed again. Been wanting to the past few days but are disabled for the holidays. Speaking of which, wishing you happy holidays ahead!

    Warm regards,
    Josh

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.