Custom Fields
Re-Envisioned
Support MB Frontend Submission Custom HTML Form and Taxonomies

  • Creator
    Topic
  • #30707
    Resolved dijitalgezgin
    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #30709
    Long 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
    dijitalgezgin
    Participant

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

    Kind regards.

    #30721
    Long 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
    dijitalgezgin
    Participant

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

    #30746
    Long 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/

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