Problem:
The issue here is that the user wanted send Emails to an email address that is stored on his parent posts when his child posts are created.
Solution:
What you can do is to create a cpt called Jobs, and Job Application.
Set the Job CPT as the Parent of the Job Application. Now on the Jobs CPT you can create an email field so that the recruiter can post a Job and the email that the Job applications should be sent to.
Then Create a CRED form for your Job Applications and then add the CRED form child post link to your Jobs, if you are using a content template then you can simply just add the child post form link to the there.
On your child post form you can add a generic field like this.
[cred_generic_field field='parent-email' type='email' class='parent-field-replacement' urlparam=''] { "required":0, "validate_format":0, "persist":1, "default":"" } [/cred_generic_field]
Then create a notification for this field in CRED.
Finally you will need to add this hook to your functions.php which will copy the Email from the Parent Job into the child post being created so that the notification will be sent to the person who created the job.
add_action('cred_before_save_data', 'my_before_save_data_action',10,1); function my_before_save_data_action($form_data) { // if a specific form if ($form_data['id']==2981) { if(isset($_POST['_wpcf_belongs_job_id']) and $_POST['_wpcf_belongs_job_id']!=""){ $parent_post_id = $_POST['_wpcf_belongs_job_id']; $x = get_post_meta($parent_post_id,'wpcf-job-email',true); $_POST['parent-email'] = $x; } } }
In the code above I create 3 things:
1. CPT called Jobs with the slug job, you can see i'm getting the ID of the parent Job by referencing is with "_wpcf_belongs_job_id" If you're using a different slug you will need to replace all instance of "_wpcf_belongs_job_id" with "_wpcf_belongs_{parent-cpt_slug}_id" where you will replace the {parent-cpt_slug} with the slug of your CPT
2. I made a custom field on the Job CPT called "Job Email" which gets a slug "job-email". I referenced this field with "wpcf-job-email". In your case when you create the field you will reference it by add the "wpcf-" prefix to the slug and replaceing all instances of "wpcf-job-email"
3. Finally I made the generic field "parent-email". If you use the generic field code that I sent then you can leave this as is.
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 2 replies, has 2 voices.
Last updated by 6 years, 9 months ago.
Assisted by: Shane.