Custom HTML Form and Taxonomies
Support › MB Frontend Submission › Custom HTML Form and TaxonomiesResolved
- This topic has 7 replies, 2 voices, and was last updated 3 years, 1 month ago by
Long Nguyen.
-
AuthorPosts
-
September 11, 2021 at 8:30 PM #30707
dijitalgezgin
ParticipantHi,
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.
September 12, 2021 at 12:22 PM #30709Long Nguyen
ModeratorHi,
The extension MB Frontend Submission only supports displaying a classic submission form. You can try to use the action hook
rwmb_frontend_before_form
andrwmb_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
September 13, 2021 at 2:02 AM #30718dijitalgezgin
ParticipantAre you have any example codes custom post types and custom meta fields for the frontend form?
Kind regards.
September 13, 2021 at 12:13 PM #30721Long Nguyen
ModeratorHi,
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>'; } );
September 13, 2021 at 5:48 PM #30728dijitalgezgin
ParticipantHow can I add and save custom taxonomies and meta fields? Can you send me PHP codes for thats?
September 14, 2021 at 10:23 AM #30746Long Nguyen
ModeratorHi,
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/
April 2, 2022 at 3:17 AM #35416dijitalgezgin
Participant@longnguyen Can I use the meta fields on the front end submission?
Kind regards.
April 4, 2022 at 10:10 AM #35440Long Nguyen
ModeratorHi,
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
-
AuthorPosts
- You must be logged in to reply to this topic.