Creating a Testimonial System using WordPress Creation Kit

, ,

First step is to create the Post Type under the Post Type Creator.  Under Supports: you should only leave title checked off.  For post_type in the example I am giving I used ‘wpcmsninja_reviews' but you can set this to whatever you would like, just need to make sure you customize the code below as needed.

After you create the post type you need to go to Custom Fields Creator and create the Custom Meta Box.  Here you will want to name it something unique, select wpcmsninja_reviews as the post type, repeater remains false, sortable should be set to true so you can control the order the reviews show in.  Next we will be adding in the fields you wish to record: Review, Review Author, and Review Email. Review I set to a textarea field type that is required with number of rows set to 5.  I put in a description of “This testimonial will be visible to the public.” for Review.  Review Author I set to a text field type that was also set to be required.  I set the description for Review Author to “Your name will be visible to the public.”.  Review Email I set to a text field type and also made it required.  I set the description for the email to “Your email will be kept private. ” because I decided not to show the email address of the review inside the template.  You can add any field you would like here if you would like to collect any other info.  You just need to make sure you look at the Field Slug that gets generated and use it in the correct spot for your code.

Next step would be to add the Options page to the post type.  Go into Option Pages Creator and add a new one with the title of “Review Options Page”. Make sure to set Page Title and under the Page Type choose Submenu Page.  Under the Parent Slug you will want to set this to the Admin URL that is the new post type, in my example I set it to: edit.php?post_type=wpcmsninja_reviews.  I then went into the Option Fields Creator and created three separate fields, To Email Address, CC Email Addresses, BCC Email Addresses.  For To Email Addresses I used that for the Group Title, I selected “Review Options Page” as the Option Page, and for the Option Name I put in to_email_address. Repeater and Sortable was set to false because there is only going to be one email address entered in here.  I then added a field with a Field Title of “To Email Address”, Field Type of text and I set required equal to true.  For the next one I used “CC Email Addresses” as the Group Title, selected “Review Options Page” as the Option Page, set “cc_email_addresses” as the Option Name, set the Repeater to True, and the Sortable to false.  I then added the “CC Email Address” field with that as the Field Title, selected text as the Field Type, and set it as a required field.  I then repeated the process for BCC Email Addresses as I did with the CC Email Addresses.

Next I went into the Swift Templates system and created a template to use.  Selected “wpcms_reviews” as the Custom Post Type, and added a Query Argument of Posts Per Page and set it to -1 so it would show all reviews.  The below template shows the template within quotes and on the next line puts a dash with the reviewers name.

<div style="padding-top:15px;">"{{{wpcmsninja_reviews_options_review}}}"
<br> - <i>{{wpcmsninja_reviews_options_review-author}}</i>
<hr />

Then on the page that you would like to have the reviews listed it is as easy as putting in the following shortcode.

[swift-template name="wpcmsninja-reviews"\

Next you will want to create a Frontend Posting form.  So you can go to this menu option and select Add New and name it “WPCMSNinja Reviews”.  For Post Type select wpcmsninja_reviews, set Anonymous Posting to yes, under Assign to user you can select anyone. I would recommend you set Admin Approval to Yes.  Under Field Type you will see “CFC-WPCMSNinja Reviews” as this is what we named the Custom Meta Boxes under the Custom Field Creator.  You can then customize the Form Labels and Messages as you see fit.  The shortcode you will use on the form page will show below the Publish or Update button.

[fep form_name="wpcmsninja-reviews"]

Here are some of the functions that I then added to my themes function file or you can also create a custom plugin.

add_filter('wck_extra_message', 'wckc_text_as_email', 10, 6);
function wckc_text_as_email($message, $field, $required_fields, $meta, $values, $id) {

  if ($field[2]['slug'] == 'reviewer-email') {
    if (!filter_var($values['reviewer-email'], FILTER_VALIDATE_EMAIL))
      return 'Please enter a valid Email Address !';

The below function sends out an email notification based on the

add_action( 'wck_fep_add_post', 'wpcmsninja_testimonial_notification' );
function wpcmsninja_testimonial_notification( $post, $user_id=0 ){
  if ( $post['post_type'] == "wpcmsninja_reviews" ) {
    $wpcmsninja_id = $post['ID'];
    $wpcmsninjaInfo = get_post_meta($wpcmsninja_id);
    //$message = "<pre>" . print_r($wpcmsninjaInfo, true) . "</pre>"; 
    $message = "Review: " . $wpcmsninjaInfo['review'][0] . "<br>\n";
    $message .= "Author: " . $wpcmsninjaInfo['review-author'][0] . "<br>\n";
    $message .= "Reviewer Email: " . $wpcmsninjaInfo['reviewer-email'][0] . "<br>\n";
    $to_email_address = get_option( 'to_email_address', '');
    $to = array( ($to_email_address[0]['to-email-address'] == '' 
      ? '[email protected]' //if no email set use this
      : $to_email_address[0]['to-email-address'] );

    $subject = 'Review for approval - Author: ' . $wpcmsninjaInfo['review-author'][0];
    $body = $message;
    $headers[] = "From: Review Submission <[email protected]>";
    $headers[] = "Reply-To: " . $wpcmsninjaInfo['reviewer-email'][0];
    $headers[] = "Content-Type: text/html; charset=UTF-8";

    $cc_email_addresses = get_option( 'cc_email_addresses');		
    if (count($cc_email_addresses) > 0 ) 
      foreach ($cc_email_addresses as $cc_email_address) {
        $headers[] = "CC: " . $cc_email_address['cc-email-address'];

    $bcc_email_addresses = get_option( 'bcc_email_addresses');		
    if (count($bcc_email_addresses) > 0 ) 
      foreach ($bcc_email_addresses as $bcc_email_address) {
        $headers[] = "BCC: " . $bcc_email_address['bcc-email-address'];

    wp_mail( $to, $subject, $body, $headers );



Posted on

September 20, 2018

Submit a Comment

Your email address will not be published. Required fields are marked *