Star Ratings Do not Save

Support General Star Ratings Do not SaveResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #38081
    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 clone the group. But the star ratings do not save. Also, when I refresh the post/page (browser F5), only one member of the cloned-group is remaining (without star rating). The other clones are no longer shown. Sceenshot here for reference.

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

    Kind regards,

    #38100
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The star rating field does not work as a subfield in a group, please register it as a top field. Let me know how it goes.

    #38103
    UnakritiUnakriti
    Participant

    Thank you Long.

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

    Will post more questions as I progress with MB.

    Appreciate your support.

    Kind regards,

    #38104
    Long NguyenLong Nguyen
    Moderator

    Let me know if you have any questions 🙂

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