Filter
uncanny-automator-pro
uap_option_get_all_txn_statuses
Filters all transaction statuses for display within MemberPress, allowing customization of available status options.
add_filter( 'uap_option_get_all_txn_statuses', $callback, 10, 1 );
Description
Fires after MemberPress transaction statuses are retrieved. Developers can use this filter to modify the array of available transaction statuses or add custom ones. This is useful for integrating with custom MemberPress transaction types or providing alternative status options within Uncanny Automator.
Usage
add_filter( 'uap_option_get_all_txn_statuses', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter is not used by the hook itself, but is passed through from the `get_all_txn_statuses` function when it's called directly.
Return Value
The filtered value.
Examples
<?php
/**
* Example: Add a custom transaction status to the list of available statuses.
*
* This filter hook allows developers to add or modify the list of transaction statuses
* that Uncanny Automator Pro can use in its automations, particularly when
* interacting with MemberPress.
*
* @param array $option The current array of transaction status options.
* @return array The modified array of transaction status options.
*/
add_filter( 'uap_option_get_all_txn_statuses', function( $option ) {
// Ensure we are dealing with the expected array structure.
if ( ! is_array( $option ) || ! isset( $option['options'] ) || ! is_array( $option['options'] ) ) {
return $option;
}
// Define our custom status. In a real scenario, this might be a status
// introduced by another plugin or a custom status specific to your needs.
$custom_status_key = 'custom_pending_review';
$custom_status_label = __( 'Custom Pending Review', 'uncanny-automator-pro' );
// Add our custom status to the 'options' array.
// The key is what will be stored, and the value is what the user sees.
$option['options'][ $custom_status_key ] = $custom_status_label;
// Optionally, update relevant tokens if you want this status to be selectable in token dropdowns.
// This part depends heavily on how Uncanny Automator Pro uses these relevant_tokens.
// For this example, we'll just add it if it exists.
if ( isset( $option['relevant_tokens'] ) && is_array( $option['relevant_tokens'] ) ) {
// Assuming the original relevant_tokens structure might have a key related to 'Status'.
// We'll add our custom status under a similar structure if it makes sense.
// This is a placeholder and might need adjustment based on actual Uncanny Automator Pro internals.
$option['relevant_tokens'][ $custom_status_key ] = $custom_status_label;
}
return $option;
}, 10, 1 );
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/memberpress/helpers/memberpress-pro-helpers.php:254
public function get_all_txn_statuses( $label = null, $option_code = 'TXN_STATUS', $args = array() ) {
if ( ! $label ) {
$label = esc_attr__( 'Status', 'uncanny-automator-pro' );
}
$args = wp_parse_args(
$args,
array(
'uo_include_any' => false,
'uo_any_label' => esc_attr__( 'Any status', 'uncanny-automator-pro' ),
)
);
$options = array(
'complete' => __( 'Complete', 'uncanny-automator-pro' ),
'failed' => __( 'Failed', 'uncanny-automator-pro' ),
'pending' => __( 'Pending', 'uncanny-automator-pro' ),
'refunded' => __( 'Refunded', 'uncanny-automator-pro' ),
);
if ( $args['uo_include_any'] ) {
$options = array( '-1' => $args['uo_any_label'] ) + $options;
}
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options' => $options,
'relevant_tokens' => array(
$option_code => esc_attr__( 'Status', 'uncanny-automator-pro' ),
),
);
return apply_filters( 'uap_option_get_all_txn_statuses', $option );
}