Filter
uncanny-automator-pro
automator_wm_default_form_field
Filters the default form fields displayed by WishList Member's automation integration before they are rendered.
add_filter( 'automator_wm_default_form_field', $callback, 10, 1 );
Description
This filter hook, `automator_wm_default_form_field`, allows developers to modify the default form fields used by Uncanny Automator for Wishlist Member integrations. Before these fields are used in automations, you can add, remove, or rename them to suit specific needs, offering granular control over user data collection within Wishlist Member workflows.
Usage
add_filter( 'automator_wm_default_form_field', 'your_function_name', 10, 1 );
Parameters
-
$fields(mixed) - This parameter contains an associative array of default form fields with their corresponding display names, used for selecting fields to be added to a form.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the 'automator_wm_default_form_field' filter hook.
* This example adds a custom field 'phone' to the default form fields
* when interacting with Wishlist Member integrations in Uncanny Automator.
*/
add_filter(
'automator_wm_default_form_field',
function ( $fields ) {
// Check if $fields is an array, as expected.
if ( ! is_array( $fields ) ) {
return $fields;
}
// Add a new field 'phone' with a translated label.
$fields['phone'] = __( 'Phone Number', 'uncanny-automator' );
// Return the modified fields array.
return $fields;
},
10, // Priority: The default priority is 10.
1 // Accepted Args: The filter accepts only one argument ($fields).
);
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/wishlist-member/helpers/wishlist-member-pro-helpers.php:145
public function get_form_fields() {
$fields = array(
'firstname' => __( 'First name', 'uncanny-automator' ),
'lastname' => __( 'Last name', 'uncanny-automator' ),
'email' => __( 'Email', 'uncanny-automator' ),
'username' => __( 'Username', 'uncanny-automator' ),
);
return apply_filters( 'automator_wm_default_form_field', $fields );
}