Filter
uncanny-automator
automator_recipe_part_type
Filters the type of a recipe part, allowing modification before it is created.
add_filter( 'automator_recipe_part_type', $callback, 10, 1 );
Description
Filters the type of a recipe part, allowing customization of whether it's free, pro, or elite. Useful for dynamically assigning premium features or restricting access. Developers can modify the `$type` based on `$post_type`, `$item_code`, or `$integration_code` to control feature availability.
Usage
add_filter( 'automator_recipe_part_type', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Modify the recipe part type based on certain conditions.
*
* For example, this could be used to dynamically change the type of a recipe part
* if it's part of a specific integration or has particular characteristics.
*
* @param mixed $type The current type of the recipe part (e.g., 'free', 'pro', 'elite').
* @param mixed $post_type The post type of the recipe part.
* @param mixed $item_code The unique code for the recipe item.
* @param mixed $integration_code The code for the integration the recipe part belongs to.
*
* @return string The modified recipe part type.
*/
function my_automator_custom_recipe_part_type( $type, $post_type, $item_code, $integration_code ) {
// If the integration code is for a premium service and the item code is for a trigger,
// let's explicitly mark this as a 'pro' type, overriding the default.
if ( 'premium_service_integration' === $integration_code && 'trigger' === $item_code ) {
return 'pro';
}
// If this is a specific post type used for internal testing and it's not already pro or elite,
// force it to be 'free' to ensure it doesn't accidentally get a premium designation.
if ( 'test_internal_recipe_part' === $post_type && ! in_array( $type, array( 'pro', 'elite' ), true ) ) {
return 'free';
}
// Otherwise, return the original type.
return $type;
}
add_filter( 'automator_recipe_part_type', 'my_automator_custom_recipe_part_type', 10, 4 );
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
src/core/lib/class-automator-functions.php:2561
}
// Set the type meta ( pro | elite | free )
if ( ! key_exists( 'type', $defaults ) || empty( $defaults['type'] ) ) {
$is_pro = isset( $config['is_pro'] ) ? (bool) $config['is_pro'] : false;
$is_elite = isset( $config['is_elite'] ) ? (bool) $config['is_elite'] : false;
$type = $is_pro ? 'pro' : ( $is_elite ? 'elite' : 'free' );
$type = apply_filters( 'automator_recipe_part_type', $type, $post_type, $item_code, $integration_code );
update_post_meta( $post_id, 'type', $type );
}
// Set the user type meta.
if ( ! key_exists( 'user_type', $defaults ) || empty( $defaults['user_type'] ) ) {
$requires_user = isset( $config['requires_user'] ) ? (bool) $config['requires_user'] : false;