Docs / Ele Conditions / Custom variables
Custom variables
Developers can register additional variables using a PHP filter. Custom variables appear in the "Type manually…" option in the Elementor panel.
Registering a variable
Add a filter to your theme's functions.php or a custom plugin:
add_filter( 'eleconditions_vars', function( $vars ) {
$vars['my_variable'] = 'my_value';
return $vars;
} );
The variable my_variable is then available in the editor via Type manually….
Example: show content only in maintenance mode
add_filter( 'eleconditions_vars', function( $vars ) {
$vars['maintenance_mode'] = get_option( 'my_maintenance_mode', 'off' );
return $vars;
} );
Condition in the editor: maintenance_mode == on
Example: WooCommerce customer data
add_filter( 'eleconditions_vars', function( $vars ) {
if ( function_exists( 'wc_get_customer_order_count' ) ) {
$user_id = get_current_user_id();
$vars['order_count'] = $user_id ? wc_get_customer_order_count( $user_id ) : 0;
}
return $vars;
} );
Condition in the editor: order_count >= 3 — show content only to repeat customers.
Example: cookie value
add_filter( 'eleconditions_vars', function( $vars ) {
$vars['consent_given'] = isset( $_COOKIE['my_consent'] ) ? $_COOKIE['my_consent'] : 'no';
return $vars;
} );
Condition in the editor: consent_given == yes
Variables registered via the filter are evaluated server-side on every page load. Keep the callback fast — avoid slow database queries in hot paths.