Filter
uncanny-automator-pro
automator_pro_trigger_update_postmeta_ignore_keys
Filters post meta keys to ignore when updating post metadata in AutomatorWP Pro.
add_filter( 'automator_pro_trigger_update_postmeta_ignore_keys', $callback, 10, 3 );
Description
Filters meta keys that the "Post meta updated" trigger should ignore. Developers can add or remove keys from the default `_edit_lock` array to prevent unnecessary trigger executions. This hook fires *after* a post meta value is updated.
Usage
add_filter( 'automator_pro_trigger_update_postmeta_ignore_keys', 'your_function_name', 10, 3 );
Parameters
-
$post_id(mixed) - This parameter contains an array of meta keys that should be ignored when triggering updates for post meta values.
-
$meta_key(mixed) - This parameter represents the ID of the post whose meta data was updated.
-
$_meta_value(mixed) - This parameter represents the meta key of the post that is being updated.
Return Value
The filtered value.
Examples
/**
* Example of how to use the 'automator_pro_trigger_update_postmeta_ignore_keys' filter.
*
* This example adds 'my_custom_ignore_key' to the list of meta keys that
* Uncanny Automator should ignore when tracking post meta updates for triggers.
*
* @param array $ignore_keys The current array of meta keys to ignore.
* @param int $post_id The ID of the post being updated.
* @param string $meta_key The meta key that was updated.
* @param mixed $meta_value The new meta value.
*
* @return array The modified array of meta keys to ignore.
*/
function my_automator_ignore_postmeta_keys( $ignore_keys, $post_id, $meta_key, $meta_value ) {
// Add a custom meta key that should also be ignored by Uncanny Automator triggers.
$ignore_keys[] = 'my_custom_ignore_key';
// You could also add conditional logic here, for example, only ignore keys for a specific post type.
// $post_type = get_post_type( $post_id );
// if ( 'my_custom_post_type' === $post_type ) {
// $ignore_keys[] = 'another_key_for_my_post_type';
// }
return $ignore_keys;
}
add_filter( 'automator_pro_trigger_update_postmeta_ignore_keys', 'my_automator_ignore_postmeta_keys', 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
uncanny-automator-pro/src/integrations/wp/triggers/anon-wp-postmetaspecificvalue.php:146
uncanny-automator-pro/src/integrations/wp/triggers/wp-postmetaspecificvalue.php:142
*
* @param $meta_id
* @param $post_id
* @param $meta_key
* @param $meta_value
*/
public function updated_post_meta_data( $meta_id, $post_id, $meta_key, $_meta_value ) {
$ignore_meta_keys = apply_filters( 'automator_pro_trigger_update_postmeta_ignore_keys', array( '_edit_lock' ), $post_id, $meta_key, $_meta_value );
if ( in_array( $meta_key, $ignore_meta_keys, true ) ) {
return;
}
$user_id = get_current_user_id();