Skip to content

Automations condition for post category #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MichelleBlanchette opened this issue Jan 13, 2025 · 3 comments
Open

Automations condition for post category #245

MichelleBlanchette opened this issue Jan 13, 2025 · 3 comments
Labels
new feature New feature to be added user request Reported by a user

Comments

@MichelleBlanchette
Copy link
Collaborator

A user has requested:

I'm trying to setup a new Asana task creation automation on post create but I need to filter the run only if the post category = 123

There is any simple way to achieve category post filter?

There may be complexity around posts actually being assigned several categories, where all the current conditions are for single value field comparisons. This means we may need different comparison operators... 🤔

Also, what about custom taxonomies? What about parent vs subcategory vs grandchild etc. levels?

@MichelleBlanchette MichelleBlanchette added enhancement Existing feature enhancements user request Reported by a user labels Jan 13, 2025
@MichelleBlanchette MichelleBlanchette self-assigned this Jan 13, 2025
@MichelleBlanchette MichelleBlanchette added new feature New feature to be added and removed enhancement Existing feature enhancements labels Jan 13, 2025
@MichelleBlanchette
Copy link
Collaborator Author

Seems it will require custom handling since that's from a separate database table (taxonomies).

This should likely be a PRO feature which also supports any registered taxonomies/terms on the site rather than only the core 'category' taxonomy. See https://developer.wordpress.org/reference/functions/get_the_category/

@MichelleBlanchette
Copy link
Collaborator Author

I just did an investigation. The categories are not available when the Post is Created Automation trigger event fires.

The hook even fired after I had already selected the desired categories. It just still processed the post as being "uncategorized".

Debug line in completionist/src/includes/automations/class-automation.php
Screenshot 2025-01-14 at 8 06 58 PM

Gave this output

[15-Jan-2025 01:05:47 UTC] PHP Notice:  Array
(
    [0] => WP_Term Object
        (
            [term_id] => 1
            [name] => Uncategorized
            [slug] => uncategorized
            [term_group] => 0
            [term_taxonomy_id] => 1
            [taxonomy] => category
            [description] => 
            [parent] => 0
            [count] => 0
            [filter] => raw
        )

)
 in /var/www/html/wp-content/plugins/completionist-pro/lite/completionist/src/includes/automations/class-automation.php on line 159
[15-Jan-2025 01:05:47 UTC] Successfully ran action for Completionist Automation hook name: wp_insert_post

with various categories set BEFORE the hook fired
Screenshot 2025-01-14 at 8 10 50 PM

@MichelleBlanchette
Copy link
Collaborator Author

I did just confirm the post's set categories are available when using the Post is Updated trigger instead.

This would mean #57 would be a higher priority to limit the number of times the Automation is triggered. For example, if I say "post is updated > status equals pending", then the Automation will run every time a post with that status is updated (not ONLY when the status BECOMES "pending").

@MichelleBlanchette MichelleBlanchette removed their assignment Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature to be added user request Reported by a user
Projects
None yet
Development

No branches or pull requests

1 participant