Skip to main content

PhP Function Output

Call any PHP function directly from GraphQL queries using php_function_output() Pro Feature. This extends your queries with core PHP functions, WordPress functions, plugin functions, and custom PHP functions.

PHP Function Output Syntax​

Call any PHP function directly from GraphQL queries using php_function_output():

General syntax:

php_function_output(
function: "function_name"
arguments: [arg1, arg2, arg3]
fallback: default_value
)

Parameters:

  • function (required) - Name of the PHP function to call
  • arguments (optional) - Array of arguments to pass to the function
  • fallback (optional) - Default value if function fails or doesn't exist

WordPress Functions​

Functions that don't require arguments:

{
# Check if user is logged in
is_logged_in: php_function_output(function: "is_user_logged_in")

# Get current user ID
current_user_id: php_function_output(function: "get_current_user_id")

# Get site information
site_logo: php_function_output(function: "get_site_icon_url")
site_url: php_function_output(function: "home_url")
}

Plugin Integration Examples​

Access plugin-specific functions for extended functionality:

{
# Get ACF options page values
company_logo: php_function_output(
function: "get_field",
arguments: ["company_logo", "option"]
)

# Get all field groups
field_groups: php_function_output(
function: "acf_get_field_groups"
)

# Get field configuration
hero_field_config: php_function_output(
function: "acf_get_field",
arguments: ["field_hero_image"]
)

post {
# Get formatted ACF value
formatted_date: php_function_output(
function: "get_field",
arguments: ["event_date", "{{wp.post.ID}}", false]
)
}
}

Complex Argument Structure​

{
# Get related posts & exclude current post
post {
ID
related: php_function_output(
function: "get_posts",
arguments: [{
post_type: "post",
posts_per_page: 3,
post_not_in: ["{{ID}}"]
}]
)
}
}

GraphQL Variables in PHP Function Output​

Variable syntax

  • {{field_name}} - Data from current object (post, user, term)
  • [[global_variable]] - Site-wide data or custom query results
{
post {
ID @private
post_title @private

# Use current post title and site title from built-in Data Variable in function
custom_title: php_function_output(
function: "sprintf",
arguments: ["%s - %s", "{{post_title}}", "[[wp.site_title]]"]
)
}
}
Security Features

php_function_output applies security restrictions to prevent database modifications: This is an important Builderius feature, and prevents a whole class of security breaches that plague other visual builders.

❌ You cannot use wp_insert_post(), wp_update_post()

❌ You cannot use wp_insert_user(), update_user_meta()

❌ You cannot execute INSERT, UPDATE, DELETE queries

✅ You can use any read-only function (get_*, wp_get_*, is_*, has_*)

Always provide fallbacks for:

  • Plugin functions that might not exist
  • Functions that depend on external data
  • Custom functions from themes or plugins

Use php_function_output() to bridge the gap between GraphQL queries and the full WordPress PHP ecosystem, enabling access to any WordPress, plugin, or custom functionality within your templates.