This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here is that the user wanted his users to be able to subscribe to a notification type. Lets say the user has a Job type and wants to notify user when they subscribe to a notification of a particular job type.
Solution:
This can be done by creating a secondary CPT for the notifications where the user can create the notification type they want for a job.
So on this notification cpt it should have attributes from the Jobs CPT that can be used to match a notification for a Job type. The notification CPT must also have an email field.
Then you can use this code below to send an email to a notification post based on a matching custom field criteria.
the code does not check if a match to the job exists. it just proofs if there is more than 0 attributes selected.
this is how the function works now:
e.g.
the alarm has attribute A and the job has attribute A the mail triggers. Excellent ? one is matching
the alarm has attribute A and the job has attribute A, B the mail triggers. Excellent ? at least one is matching
the alarm has attribute A and the job has attribute B the mail triggers. Not good ;-( cause nothing is matching
If the Job type is equal to the notification type AND at least 1 of the notifications stelle matches what is on the job. If those 2 conditions are not met then the email will not be sent.
But you're saying the email is sent when the Notification type and Job type is matching and there are no matching job and notification stelle . This is pretty much not possible to happen with this like of code because both sides must be true if the code is to work.
you are absolute right. the function does work. there is only one little problem in the last part of the function.
"If the Job type is equal to the notification type" (this part works fine/ so no problems here)
AND "at least 1 of the notifications stelle matches what is on the job". (this section is not right: it deos not check if there is a match - it only checks if one or more things are selected.
i have shot some screenshots to explain it more in detail 🙂
Hope this helps.
So I was able to find the issue as to why it wasn't working.
But its a little more complex that i had imagined and this is because of how the fields are stored. It will take some time for me to go through and create the final solution so you will see alot of jobs created on your site.
This may take some time as the issue that i'm having right now is that the custom checkbox uses a multidimensional array.
I need to break this array up to get out the values and rebuild it into a single dimensional array that can be compared using the default php function.
Thank you soooo uch for going the extra mile with that.
Could you give me an example of adding a new mulstiselect field to the function?
Because you add same more code un the childs function.
This would be great. So i am able to extend the function to my needs.
My apologies. I was actually to remove this because it was for testing purposes.
I created a shortcode to see if I could manually print out the values. I was able to and thats how I knew that the format of the checkboxes were a multidimensional array. You can actually remove it because its not needed.