Skip Navigation

[Resolved] impossible to target page child post page

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to automatically send notification to his parent cpt.

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 support ticket is created 6 years, 8 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 – 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 15 replies, has 2 voices.

Last updated by ericW-5 6 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#625676

with reference to our former discussion : https://toolset.com/forums/topic/sending-info-to-post-author/, all suggested steps have been done. But I have a problem to target the child post page.

I am building a job site . There are Jobs and applications for the jobs, therefore I created post relationships where a job is parent and applications are children.

Now I want to access the child post form (hidden link) from the job page template ('Modèle pour Offres' d'emploi) but the page is not found. See screenshot.

Thanks for your help

#625677
postuler.PNG

thanks in advance
eric

#625774

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

I'm having a bit of difficulty trying to understand what you want to achieve based on the links you sent.

Is it that you want to display the child post form on the actual job itself instead of clicking a link to apply for the job ?

Please let me know.
Thanks,
Shane

#625929
postuler2.PNG

Hi Shane,
sorry if I was unclear, I will give you more details.

Here is what I am trying to do
NB : I set up a relationship where CPT "Offres d'emploi" (jobs) is parent and "réponses offres" (applications) is child.

1- When candidates click on a specific job they should see the job details and see an apply button (postuler)

Jobs are listed on this page : hidden link using a view called "recherche emploi" and I have a content template for the job details called "Modèle pour Offres d'emploi"
--> This works fine

2- when candidates click on apply/postuler, they access another page with the job name (post name) they want to apply and their resume or a link to their resume is automatically embedded in the application form. They simply have to click the submit button to send their application.

I used a CRED form called "Repondre-a-offre" to apply. It is displayed on page hidden link.
Candidates can create a resume using a CRED form called "Publier_candidature" linked to the CPT "candidatures".
--> This does not work : I don't know how to get the parent post name + this candidates' resume on the application form

3- the job author (recruiter) is notified by email and he can see the application

I added the following in my child post to get the parent email
[cred_generic_field field='parent-email' type='email' class='parent-field-replacement' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":""
}
[/cred_generic_field]

and I also added this code you provided in my functions.php file :
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;

}
}
}

--> This does not work, I only have the code shown on the page (see file attached) and the parent post author (recruiter) receives nothing.

4- I would need the number of resumes to be limited to one per candidate. I tried your suggested plugin (hidden link) with no success. Would you have another solution.

Thanks in advance for your help
Eric

#626293

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

I see a few issues here but I have one question to ask.

This CPT here hidden link

Should this be the child post type of the offre-d-emploi CPT?

Please let me know.
Thanks,
Shane

#626379

Hi Shane;

- "candidatures" (hidden link) is where candidates provide their resumes in the resume database.
- Recruiters can search this resume database to find/contact a candidate or publish a job offer (offre d'emploi) and wait for candidates to apply.
- "réponses offres" (hidden link) is where candidates apply for a specific job offer, therefore they are the child post type of "offres d'emploi" (hidden link)

I would like to automatically include the candidate's resume in his application for a specific job offer : this could be a link to the resume or the resume itself.

Thanks
Eric

#626736

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

So the form that we should be creating is for réponses offres

Because this is where the user's application will be stored. I'm still a bit confused about the candidatures cpt because the user can simply upload his/her resume to the responses offres CPT when applying for a job offer.

I see you have this form here.
hidden link

Please let me know.
Thanks,
Shane

#626844

Hi Shane,

1. I confirm the form that we should be creating is for réponses offres because this is where the user's application will be stored. And yes I already have a form : hidden link
But this does not work properly as I explained in the above message on march 18th : I need to get the parent post name/title + the candidate's resume displayed in the application form. And I also need the author of the parent post (job offer) to receive this application.
Please have a look, this does not work at present.

2. Candidates could upload a new resume in their application form. But as they have stored a resume on the site using 'candidatures' it would be a lot simpler for them to automatically embed this stored resume in the application form or to show a link to this stored resume.

Can you please help me to get all this work properly.

Thanks in advance
Eric

#627111

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

I'm still confused as to why there is a 3rd CPT to hold the resumes themselves.

In keeping with your structure I'm assuming that the post relationship is in this format Job -> Application -> Resume where Job is the Parent of Application and Application is the Parent of Resume.

If Resume isn't in a relationship then the way we can get the resumes to appear on that form is if the user that is submitting the application is the Author of the resume post.

In this case we can add a view for resume's that filter for the resumes where the author is the currently logged in user.

So i've done a quick setup and you can see here hidden link

If you click on any Job then you can click Apply for Job and it will take you to the job with the parent already filled out.

So we have the first section down, so we can just tackle this task in simpler more manageable steps if thats ok with you.

Right now we can focus on the Child form for the application.

Please let me know if this helps.
Thanks,
Shane

#627329

Thanks a lot for this Shane.

There is a 3rd CPT to hold resumes because recruiters should be able to post job offers and receive applications but they ALSO should be able to search our resume database on the site in order to contact potential candidates matching their needs.

1. You wrote :"If Resume isn't in a relationship then the way we can get the resumes to appear on that form is if the user that is submitting the application is the Author of the resume post. In this case we can add a view for resume's that filter for the resumes where the author is the currently logged in user."
-> That is exactly what I need. So I created a view called "attached resume" which displays the logged in candidate's resume. I put this view in the application form. Is it ok ?

2. You wrote :"If you click on any Job then you can click Apply for Job and it will take you to the job with the parent already filled out." Thanks. That's what I need but here we leave the choice to select another parent. I would like to have only the right parent, not a list of all possible parents/jobs as there will be tons of job offers.

3. Then I need the recruiter to receive this application. So i inserted the your suggested code in the application form so that I can get the recruiter's email in order to send him the notification.
[cred_generic_field field='parent-email' type='email' class='parent-field-replacement' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":""
}
[/cred_generic_field]
The problem is I want the system to store the recruiter's email adress to notify the recruiter he got a new application. But I don't want to show this email address to the candidate. Can you help to do this ?

4. The recruiter needs to see applications. I don't know how to set up a "view" on the site for the recruiter to see all applications for his job offer.

Thanks in advance
Eric

#627518

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

A little more information on this.

1. For the resume's i see that you currently have this implemented.

2. We can just hide this with some css. I went in and added a div around the fields to hide them for you.

3. This has already been setup and your recruiter only should receive an email about this application.

4. So when the recruiter looks at his job on the frontend then he/she should be able to see a list of applications for this job correct?

For this you will need to create a view for the applicants and then add a parent filter to the view and select the option "Parent is the current page where view is placed".

Finally just add the view to the jobs content template and it should display the list of applicants for the jobs.

Please let me know if this helps.
Thanks,
Shane

#627848

Hi Shane,

Ok for 1-2-3. Thanks.

You wrote "4. So when the recruiter looks at his job on the frontend then he/she should be able to see a list of applications for this job correct? For this you will need to create a view for the applicants and then add a parent filter to the view and select the option "Parent is the current page where view is placed". Finally just add the view to the jobs content template and it should display the list of applicants for the jobs."

>>> I built a view called 'réponses à mes offres' where the recruiter should see applications

First I tried with your suggested filter "Parent is the current page where view is placed" but with no success as it said 'no item found'

Then I tried with a filter called (sorry for translation) "post relationship - items are children of the current page showing the parent". This almost works as i get a list with candidates names... but not their resumes. Can you please help so that recruiters can see a list of names + have access to their resumes.

And I also need to make this list of applications ONLY available to the recruiter/author of the job offer because it is currently available to anyone.

Thanks in advance
Eric

#628409

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

Right now we have the applicants being listed out.
hidden link

I've adjusted it so that the correct filter is used.

Could you let me know which CPT is the Resume CPT. I'm having difficulties understanding the translation.

Thanks,
Shane

#628415

Hi Shane,

Resumes are stored via a CPT called "Candidatures"

Thanks and regards
Eric

#628417

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eric,

Awesome, i've created this view here hidden link and added an author filter there, since the author of the resume should be the same person who is creating the application.

I then added it to the view here : hidden link

Finally this is the end result.
hidden link

Please let me know if this helps.
Thanks,
Shane