Skip Navigation

[Resolved] Allow user subscribe with specific value of custom field.

This support ticket is created 4 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 3 replies, has 2 voices.

Last updated by Jamal 4 years, 5 months ago.

Assisted by: Jamal.

Author
Posts
#1700729

Hi,

Can you help me to approach this? There is a custom type typeA, a custom field fieldA. The website allows anyone to register. Anyone can subscribe to typeA. If there are 2 conditions meet, it will trigger automatically send an email to the user.
1. A new post of typyA published.
2. The value of fieldA equals to a specific value(for example the value of a textbox is "Yes")

#1702779

Hello and thank you for contacting the Toolset support.

I am not really sure to understand your request. Please correct me if I am wrong.
You want to have a form for creating TypeA posts, the form with have a fieldA. When the user submits a new post and have a value "Yes" on the fieldA, you want the automatic notification to be sent, right? If fieldA is not equal to "Yes" the notification should not be sent, right?
If this is the case, check these previous tickets that may help:
- https://toolset.com/forums/topic/cred-form-notification-email-conditional-on-generic-field/
- https://toolset.com/forums/topic/need-filter-send-cred-emails-only-if/

If it is not the case, please explain your use case with as many details as possible in a way like:
1. I go to xxx
2. I do xxx
3. I expect to have xxx
4. Instead, I get xxx

#1704077

1. There is a custom type typeA, a custom field fieldA.
2. The website allows anyone to register. Anyn registered member can submit post of typeA.
3. In user form there are option of for subscribe email with specific value of filedA. for example:
tickbox 1 []fieldA = "Rice"
tickbox 2 []fieldA = "Noodle"
tickbox 3 []fieldA = "Pancake"
When user tick any of above checkboxes in user profile and there is a new post of typeA is published. he will get a notification email.

For example, if he tick "Rice", when there is a new typeA with the fieldA value = "Rice", he will get a notification email. If the new typeA with the fieldA value = "Noodle", he won't get email.
4. the above rule applies to all registered member.

#1706421

Thank you! Now I understand better what you want to achieve. You want users to subscribe to some topics(Rice, Noodle, Pancake), then you want them to get a notification email when a new post is published on the same topics.

This will need custom code to be implemented. You will need to build a function that will return all the users that are subscribed to a topic. Check this article, it has an example of searching for users by a user custom field https://developer.wordpress.org/reference/classes/wp_user_query/

Then you can add the emails of these users to the notification hooked function.

Or you may want to do this by your self without going through Toolset notification system. In that case, you will need to hook to the publish event and use the WordPress wp_mail function. Check these articles:
- https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post
- hidden link
- https://developer.wordpress.org/reference/functions/wp_mail/