Hello
I've had today a support chat with Waqar about this problem. But something happened and that chat was not converted to ticket so I have to create a new ticket for this.
The idea is that i have JOB post where logged in candidate-role users can apply clicking a form button. The application form is a relationship form between JOB and RESUME (candidate user can have only one resume post created).
How can I autofill this relationship form with the job ID (the id of the post the form is displayed on) and the resume ID of the candidate user who is viewing the job.
Hi,
Thank you for waiting and it is very strange that the chat from yesterday didn't converted into a ticket.
I've performed some tests on my website and this is the form's shortcode format, that needs to be used for automatically filling the child and parent posts:
[cred-relationship-form form='job-application' parent_item='$current' child_item='1234']
The "$current" attribute value will make it use the current job post's ID and "1234" is the ID of the target resume post.
To dynamically get the value of the current user's ID and then extract his/her resume post ID from it, you'll need to insert the form, through a custom shortcode, for example:
add_shortcode('show_jobs_resumes_form', 'show_jobs_resumes_form_func');
function show_jobs_resumes_form_func() {
$current_user_id = do_shortcode('[wpv-current-user info="id"]');
if(!empty($current_user_id)) {
$args = array(
'post_type' => 'resume',
'number' => 1,
'post_status' => 'publish',
'author' => $current_user_id,
);
$posts_array = get_posts( $args );
if(!empty($posts_array)) {
$resume_id = $posts_array[0]->ID;
ob_start();
echo do_shortcode('[cred-relationship-form form="job-application" parent_item="$current" child_item="'.$resume_id.'"]');
return ob_get_clean();
}
}
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.
After that, in your single job post, you can insert this form's shortcode like this:
Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar
This works perfectly Waqar! I added it through a view to the single. I set it up to show the post author's posts related to the post in the intermediary relationship. In the loop section there was a message that the author alreaty applied to the post, and in the not found section I added the shortcode you helped me with. This way the button is only shown for those who didn't apply yet.
Thank you Waqar for having so much patience for me and helping me this much with my projects.
I wich you a pleasant evening and a nice weekend (it's almost here 🙂