custom Recipient class
-
Hello,
What I am trying to accomplish is to have a notification triggered when a custom post type is published (easy), and I run a custom query to build the list of recipients for the notification (based on some settings I added with ACF plugin). It seems like I probably need to define my own Recipient class for this, which is my first approach to solve.
First thing, when I define a class which extends Abstracts\Recipient in my theme and call notification_register_recipient() with it, I do not see a new recipient type show up when editing my notification. I know the class loads and is registered, because if I reuse an existing recipient class slug like ‘administrator’ I get an error that it’s already in use. And I know the class itself works, because I can put it in the Notification code under class/Defaults/Recipient/ and register it in inc/defaults/recipients.php and it will show up as expected. So my guess is it’s something to do with the timing of when my registration is called (it’s in a theme, so all plugins_loaded hooks have fired before my code can run). Any ideas?
My next issue/question is what information does the parse_value() function have available? It seems like that is the place I should do my custom query and return an array of recipients. But I need to know the post id which triggered the “post published” notification. Or I need to know a taxonomy value from that post, if there’s an easy way for parse_value() to expand a merge tag.
And my last question/thought: is this even the right approach to solve this issue? I might try creating a custom merge tag instead, as it looks like I have access to the post id from that. It just seems like a “Recipient class” would be the right way to handle logic related to recipients, so I started there.
Thanks much!
Jesse
- The topic ‘custom Recipient class’ is closed to new replies.