• Hi,

    I am trying to make reviews fields added to comments by the YASR plugin editable with SCE. Adding the fields is not much of a problem. However I am struggling with passing the values of them. I created these two filters:

    function get_values_of_reviewfields() {
    	?>
    		<script type="text/javascript">
    			jQuery( document ).ready( function( $ ) {
    				if (typeof wp.hooks != 'undefined') {
    					wp.hooks.addFilter( 'sce.comment.save.data', function( ajax_save_params ) {
    						var name = $("#yasr-pro-visitor-review-title").val();
    						var number = $("#yasr-pro-visitor-review-rating").val();
    						var reviewfelder  {
    							title: name,
    							rating: number
    						}
    						$.extend( ajax_save_params, reviewfelder );
    						return ajax_save_params;
    					}  );
    				}
    			} ) ;
    		</script>
    	<?php
    }
    add_action( 'wp_footer', 'get_values_of_reviewfields');
    function save_review_values ( $comment_to_save, $post_id, $comment_id ) {
    	$title = $_POST[ 'title' ];
    	$rating = $_POST[ 'rating' ];
    	update_comment_meta( $comment_id, 'yasr_pro_visitor_review_title', $title );
    	update_comment_meta( $comment_id, 'yasr_pro_visitor_review_rating', $rating );
    	return $comment_to_save;
    }
    add_action('sce_save_after', 'save_review_values', 10, 3);

    It results in deleting the values of yasr_pro_visitor_review_title and yasr_pro_visitor_review_rating, so obviously field values are not passed.

  • The topic ‘Passing values of added fields.’ is closed to new replies.