Star Ratings in "Add Field" inside Field Group Editor

Support General Star Ratings in "Add Field" inside Field Group EditorResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38082
    UnakritiUnakriti
    Participant

    Hi,

    I have installed your Star Ratings plugin from GitHub and then added the following snippet:

    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $prefix = '';
        $meta_boxes[] = array(
            'title'      => esc_html__( 'Star Rating', 'text-domain' ),
            'id'         => 'star-rating',
    		'post_types' => ['review'],
    		'context'    => 'normal',
    		'fields' => array(
    		array(
    	            'id' 		=> 'rating',
    		        'type' 		=> 'group',
    		        'clone' 	=> true, // ALLOW “RATING” GROUP TO BE CLONED
    		        'add_button' 	=> '+ Add Group',
    				'autosave' 	=> true, // try autosave?
    				'fields'     	=> array(
            		    	array(
    		                'id'   => $prefix . 'name',
            		        'type' => 'text',
            		        'name' => esc_html__( 'Name', 'text-domain' ),
    						'autosave' 	=> true, // try autosave?
            			),
            	    		array(
            	        	'id'   		=> $prefix . 'rating',
            	        	'type' 		=> 'rating',
            	        	'name' 		=> esc_html__( 'Rating', 'text-domain' ),
    						'autosave' 	=> true, // try autosave?
            	    		),
            		),
            	),
    		),
    	);
        return $meta_boxes;
    }

    I can see the Star Rating custom field type on the post type because I specify the post_type in my code.

    However, I want to make this field available in the Custom Fields "Add Field" button of the Field Group editor - screenshot for reference.

    Can you please help with the correct code to achieve this?

    Kind regards,

    #38101
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If you want to add your own field type to the builder, please follow this documentation https://docs.metabox.io/extensions/meta-box-builder/#adding-your-own-field-types

    #38102
    UnakritiUnakriti
    Participant

    Thank you Long.

    I sincerely wish to use MB more productively and keep learning. But, for lack of time on this one, I will just need to consider a popular star rating plugin such as YASR.

    Appreciate your support.

    Kind regards,

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