If a user is logged in, after his first submit his company details will save to his user profile.
When he goes to post again, the fields are prefilled.
This works on the frontend job submission form.
Thread Starter
bflow
(@bflow)
Thanks for your fast answer.
Yes I know that. But I’d like to prefill those fields with the data form the user profiles (just in the frontend). Especially uploading the logo again will be “too much work” for many people – I’m afraid.
I’d be really glad, if you know a solution!
I guess that would only make sense if ‘companies’ are signing up to your site. If its individuals, your pre-filled fields would be wrong anyway.
The examples in https://wpjobmanager.com/document/editing-job-submission-fields/ can be used.
e.g. write a custom function (hooked in like the examples) which gets your user data from wherever and sets:
$fields['company']['company_logo']['value']
to something else.
Thread Starter
bflow
(@bflow)
thanks for your help but I didn’t get it to work so far.
I can change the label of the company_name but I can’t set the value. I tried it just easy with “test value” but it does not show up when I log in to the FE. Also with a new user that does not work…
Sorry for bothering you that much!
I tried it like this:
add_filter( 'submit_job_form_fields', 'custom_submit_job_form_fields' );
function custom_submit_job_form_fields( $fields ) {
$fields['company']['company_name']['value'] = "Test value";
// And return the modified fields
return $fields;
}
Hope you can tell me what the problem is. Thanks alot anyways!
Try the later filter from:
self::$fields = apply_filters( 'submit_job_form_fields_get_user_data', self::$fields, get_current_user_id() );
submit_job_form_fields_get_user_data is run just after getting the user meta data. Try that instead.
Thread Starter
bflow
(@bflow)
thanks again for your help!
unfortunately I don’t really get what I need to do now to get this working.
Would it be possible to hire you, for doing that for me?
If you have no time for that, don’t worry and thanks anyways 🙂
I think you just need to swap submit_job_form_fields in your code to submit_job_form_fields_get_user_data. Let me know if it has no effect.
Thread Starter
bflow
(@bflow)
Thank you SO much!
It works now with the following code. Maybe someone else can use it aswell:
// Add your own function to filter the fields
add_filter( 'submit_job_form_fields_get_user_data', 'custom_submit_job_form_fields' );
// This is your function which takes the fields, modifies them, and returns them
function custom_submit_job_form_fields( $fields ) {
// Here we target one of the job fields (job_title) and change it's label
$fields['company']['company_name']['value'] = get_user_meta( get_current_user_id(), 'display_name', ture);
$fields['company']['company_website']['value'] = get_user_meta( get_current_user_id(), 'user_url', ture);
$fields['company']['company_tagline']['value'] = get_user_meta( get_current_user_id(), 'description', ture);
$fields['company']['company_logo']['value'] = get_user_meta( get_current_user_id(), 'user_pic', ture);
// And return the modified fields
return $fields;
}