Back to Developer Guides

This guide applies to:

  • Basic Edition
  • Plus Edition
  • Pro Edition
  • Business Edition

Description

WordPress filter that enables access to the template variables. This allows you to add new Twig variables that can be used in notifications.

Visit our Advanced Twig and Basic Twig guides to get a feel of what can be accomplished with this filter.

Placement

This code should be placed in the file of your custom plugin.

Source Code

This filter is located in the SSA_Templates::get_template_vars() function in class-templates.php.


Usage for ssa/templates/get_template_vars Filter

add_filter('ssa/templates/get_template_vars', 'new_function_name', 10, 2);

Parameters

  • $vars array
    The variables of the template.
  • $template

Example – Add Custom Twig Variable

add_filter('ssa/templates/get_template_vars', 'add_custom_var', 10, 2);

function add_custom_var($vars, $template)
{
    $vars['new_custom_variable'] = 'My custom variable';
    return $vars;
}

Still stuck?

File a support ticket with our five-star support team to get more help.

File a ticket

  • Please provide any information that will be helpful in helping you get your issue fixed. What have you tried already? What results did you expect? What did you get instead?
  • This field is for validation purposes and should be left unchanged.


Related Guides