Render Custom field on front end form
-
Similarly to what functionality appears to be available within
includes/admin/class-forms.php
in which, if the type of a field does not have an accompanying'render_'. $data['type']
method (e.g.render_media( $field_data)
. I would like to be able to do this within the front end of the site.The use case I have is as follows, I have overridden the
job-submission.php
template within my theme, in which I would like to add a new file upload (which would want to be either a.pdf
or.docx
format). For this I would add something like the following to my$job_details_fields
array.Plain Textarray( 'type' => 'media', 'label' => __( 'Job Application Form', 'jobboardwp' ), 'id' => 'application_form', 'action' => 'upload-application-form', 'value' => $application_form,),
This would then be accompanied by an action added to
functions.php
to leverage functionality similar to the belowrender_field_by_hook($data)
found withinincludes/admin/class-forms.php
except this would be part ofincludes/frontend/class-forms.php
.Plain Textpublic function render_field_by_hook( $data ) {??????/**?????? * Filters the custom field content.?????? *?????? * Note: You could use this hook for getting rendered your custom field in wp-admin Forms.?????? *?????? * @since 1.1.0?????? * @hook jb_render_field_type_{$field_type}?????? *?????? * @param {string} $content Field content. It's '' by default.?????? * @param {array} $data Field data.?????? * @param {array} $form_data Admin form data.?????? * @param {object} $form Admin form class (\jb\admin\Forms) instance.?????? *?????? * @return {string} Rendered custom field content.?????? */??????return apply_filters( 'jb_render_field_type_' . $data['type'], '', $data, $this->form_data, $this );????}
Is there something within the plugin that already provides this extensibility that I have missed? if not, is there a justification for this?
- You must be logged in to reply to this topic.