SOLVED: Conditions: Dynamic Data - {echo:my_function} is not working / failing

Hi Bricks team,

I’m currently trying to use a custom PHP function inside a condition (in this manner) using the dynamic data tag {echo:has_child_product_categories()} — however, the condition never evaluates correctly, even when the function returns a hardcoded '1'.

What I’m doing:

I created this simple function via Code Snippets:

function has_child_product_categories() {
    return '1'; // hardcoded for testing
}

Then, in the conditions panel of a Bricks element, I set:

image

I have tried to set:
{echo:has_child_product_categories()}
and
{echo:has_child_product_categories}

The result: the element never shows, as if the condition fails.
I also tested outputting the function directly via a <code> block, and it correctly returns '1'.

I’ve tried returning as integer 1, and boolean true and nothing worked.

Environment:

  • Bricks version: v2.x
  • Dynamic data works in content (like in a code block or shortcode), but not in condition fields
  • Custom function is loaded using WPCodeBox set to “Always (on page load)” and tested via echo successfully.

Expected:

The condition should pass and render the element when the function returns '1'.

Actual:

The element is never rendered, regardless of the return value.

Could this be a bug in how Bricks parses or executes echo: in condition logic?

Thanks in advance — happy to provide a demo page or credentials if needed.

Hey @jcmatoskx,

I’m just checking: Did you allow the execution of this function?

Matej

1 Like

Hey Matej thank you for helping me out with this,
Could you clarify what you mean?

I admit I feel kinda dumb, I tried to search through the documentation but this is all I found
I have enabled here Code Execution,
is there somewhere in specific In bricks where need to allow the execution of this function

Ok actually I got it :slight_smile:

here is the documentation, I was not aware you had to manually add a code snippet to allow specific function execution in Bricks so issue fixed! thank you very much

1 Like

Hi @jcmatoskx,

yep, that’s it. I’ll mark this topic as solved, and I marked your answer as a solution :slight_smile:

Thanks, and sorry for not replying earlier :face_with_peeking_eye:
Matej

1 Like