Filter
uncanny-automator-pro
uap_option_list_all_give_recurring_forms
Filters the list of recurring donation forms available for integration with the Give plugin, allowing customization of available options.
add_filter( 'uap_option_list_all_give_recurring_forms', $callback, 10, 1 );
Description
This filter allows developers to modify the list of available options for recurring donation forms from GiveWP within Uncanny Automator Pro. You can add, remove, or alter existing options to customize how recurring donation data is used in your automations.
Usage
add_filter( 'uap_option_list_all_give_recurring_forms', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter is a mixed type that receives the option value being filtered.
Return Value
The filtered value.
Examples
// Example of how to modify the list of recurring form options for GiveWP in Uncanny Automator Pro.
// This example would add a custom field to be available in the dropdown for triggers/actions.
add_filter( 'uap_option_list_all_give_recurring_forms', 'my_custom_give_recurring_form_options', 10, 1 );
function my_custom_give_recurring_form_options( $options ) {
// Let's assume we want to add the 'billing_frequency' for recurring donations.
// First, we need to check if the input $options is an array and has the expected structure.
if ( ! is_array( $options ) || ! isset( $options['options'] ) || ! is_array( $options['options'] ) ) {
return $options; // Return original options if the structure isn't as expected.
}
// We'll target the 'form_id' key as the base for our new option.
// The original code maps 'form_id' to '_ID', 'recurring_amount' to '_AMOUNT', etc.
// We'll create a new option that is appended to the existing ones.
$options['options'][key( $options['options'] ) . '_BILLING_FREQUENCY'] = esc_attr__( 'Billing Frequency', 'your-text-domain' );
// You could also modify existing options if needed, but here we're adding.
// For example, if you wanted to rename 'Donor name' to 'Payer Name':
// if ( isset( $options['options'][key( $options['options'] ) . '_DONOR'] ) ) {
// $options['options'][key( $options['options'] ) . '_DONOR'] = esc_attr__( 'Payer Name', 'your-text-domain' );
// }
return $options;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/give/helpers/give-pro-helpers.php:189
public function list_all_give_recurring_forms( $label = null, $option_code = 'MAKEDONATION', $args = array() ) {
if ( ! $label ) {
$label = __( 'Form', 'uncanny-automator' );
}
$token = key_exists( 'token', $args ) ? $args['token'] : false;
$is_ajax = key_exists( 'is_ajax', $args ) ? $args['is_ajax'] : false;
$is_any = key_exists( 'is_any', $args ) ? $args['is_any'] : false;
$target_field = key_exists( 'target_field', $args ) ? $args['target_field'] : '';
$end_point = key_exists( 'endpoint', $args ) ? $args['endpoint'] : '';
$options = array();
if ( $is_any ) {
$options['-1'] = __( 'Any form', 'uncanny-automator-pro' );
}
$query_args = array(
'post_type' => 'give_forms',
'posts_per_page' => 9999,
'post_status' => 'publish',
);
$all_forms = Automator()->helpers->recipe->wp_query( $query_args );
$type = 'select';
global $wpdb;
foreach ( $all_forms as $opt => $val ) {
$query = "SELECT meta_value FROM {$wpdb->prefix}give_formmeta WHERE form_id = {$opt} AND meta_key LIKE '_give_recurring'";
$not_recurring = $wpdb->get_var( $query );
if ( ! empty( $not_recurring ) && $not_recurring != 'no' ) {
$options[ $opt ] = $val;
}
}
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => $type,
'required' => true,
'supports_tokens' => $token,
'is_ajax' => $is_ajax,
'fill_values_in' => $target_field,
'endpoint' => $end_point,
'options' => $options,
'relevant_tokens' => array(
$option_code => esc_attr__( 'Form title', 'uncanny-automator-pro' ),
$option_code . '_ID' => esc_attr__( 'Form ID', 'uncanny-automator-pro' ),
$option_code . '_AMOUNT' => esc_attr__( 'Recurring amount', 'uncanny-automator-pro' ),
$option_code . '_DONOR' => esc_attr__( 'Donor name', 'uncanny-automator-pro' ),
$option_code . '_DONOREMAIL' => esc_attr__( 'Donor email', 'uncanny-automator-pro' ),
),
);
return apply_filters( 'uap_option_list_all_give_recurring_forms', $option );
}