Custom HTML Form and Taxonomies

Support MB Frontend Submission Custom HTML Form and TaxonomiesResolved

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #30707
    dijitalgezgindijitalgezgin
    Participant

    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.

    #30709
    Long NguyenLong Nguyen
    Moderator

    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

    #30718
    dijitalgezgindijitalgezgin
    Participant

    Are you have any example codes custom post types and custom meta fields for the frontend form?

    Kind regards.

    #30721
    Long NguyenLong Nguyen
    Moderator

    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>';
    } );

    Result: https://share.getcloudapp.com/p9ukZw94

    #30728
    dijitalgezgindijitalgezgin
    Participant

    How can I add and save custom taxonomies and meta fields? Can you send me PHP codes for thats?

    #30746
    Long NguyenLong Nguyen
    Moderator

    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/

    #35416
    dijitalgezgindijitalgezgin
    Participant

    @longnguyen Can I use the meta fields on the front end submission?

    Kind regards.

    #35440
    Long NguyenLong Nguyen
    Moderator

    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.