Support Forum
Support › MB Frontend Submission › Custom HTML Form and TaxonomiesResolved
Hi,
How I can a create custom form (own html form). Also I want to add taxonomies and meta fields to the form?
Is there any documentation and example code?
Kind regards.
Hi,
The extension MB Frontend Submission only supports displaying a classic submission form. You can try to use the action hook rwmb_frontend_before_form
and rwmb_frontend_after_form
to add some HTML code and add your own CSS code to re-style the form.
Please get more details here https://docs.metabox.io/extensions/mb-frontend-submission/#hooks-1
Are you have any example codes custom post types and custom meta fields for the frontend form?
Kind regards.
Hi,
Here is an example shortcode to create the custom post type and custom fields on the frontend
[mb_frontend_form id="meta-box-id" post_fields="title,content" post_type="post-type-slug"]
And the code to add HTML code to wrap the form
add_action( 'rwmb_frontend_before_form', function( $config ) {
echo '<div class="my-custom-class">';
} );
add_action( 'rwmb_frontend_after_form', function( $config ) {
echo '</div>';
} );
How can I add and save custom taxonomies and meta fields? Can you send me PHP codes for thats?
Hi,
You can create the field taxonomy to add the taxonomy for the post on the frontend. Other custom fields will work like that.
For example: the code to creates a meta box and custom fields
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Post Meta', 'your-text-domain' ),
'id' => 'post-meta',
'post_types' => ['page'],
'fields' => [
[
'name' => __( 'City', 'your-text-domain' ),
'id' => $prefix . 'city',
'type' => 'text',
],
[
'name' => __( 'Taxonomy', 'your-text-domain' ),
'id' => $prefix . 'taxonomy_j6xupbwl47k',
'type' => 'taxonomy',
'taxonomy' => ['category'],
'field_type' => 'select_advanced',
],
],
];
return $meta_boxes;
}
Frontend shortcode: [mb_frontend_form id="post-meta" post_fields="title,content" post_type="page"]
Please read more on the documentation https://docs.metabox.io/extensions/mb-frontend-submission/
@longnguyen Can I use the meta fields on the front end submission?
Kind regards.
Hi,
Yes, you can use other custom fields in the frontend submission form. Just add the meta box (field group) ID to the shortcode. See this reply https://support.metabox.io/topic/custom-html-form-and-taxonomies/#post-30721