Contact Form Entries Shortcode

Below, you’ll find a detailed guide on how to add the Contact Form Entries Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Contact Form Entries Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Contact Form Entries Plugin and the shortcodes it provides:

Plugin Icon
Database for Contact Form 7, WPforms, Elementor forms

"Database for Contact Form 7, WPforms, Elementor forms is a versatile plugin that efficiently manages your form entries. It offers seamless integration with Contact Form 7, WPforms, and Elementor forms for easy data collection."

★★★★☆ (94) Active Installs: 60000+ Tested with: 6.3.2 PHP Version: 5.3
Included Shortcodes:
  • [vx-entries]

Contact Form Entries [vx-entries] Shortcode

The ‘vx-entries’ shortcode from the Contact Form Entries plugin is designed to fetch and display form entries. It accepts various attributes to customize the output. This shortcode allows you to specify the form id or name, limit the number of entries, set the start point for entries, and adjust the font size. You can also define the columns to display and their labels, and style the table with custom CSS classes. Additionally, it provides options to enable search and export functionalities, and set the user id to fetch entries from a specific user. The output is displayed in a sortable table with optional pagination.

Shortcode: [vx-entries]

Parameters

Here is a list of all possible vx-entries shortcode parameters and attributes:

  • form-id – Specifies the ID of the contact form.
  • form-name – Specifies the name of the contact form.
  • cols – Specifies the number of columns to display.
  • col-start – Identifies the starting column for display.
  • col-labels – Specifies the labels of columns to display.
  • font-size – Defines the font size of the table text.
  • class – Adds a CSS class to the table.
  • id – Gives a unique identifier to the table.
  • limit – Controls the number of entries displayed.
  • start – Specifies where to start displaying entries.
  • search – Enables search functionality.
  • export – Enables the export of entries.
  • per-page – Specifies number of entries per page.
  • user-id – Defines the user ID to filter entries.
  • sortable – Enables the sorting of table columns.
  • pager – Adds pagination to the table.

Examples and Usage

Basic example – Displays entries of a specific form by referencing its ID.

[vx-entries form-id=1 /]

Advanced examples

Displaying entries of a form identified by its name. If the form with the given name doesn’t exist, the shortcode won’t return any entries.

[vx-entries form-name="Contact Us" /]

Limiting the number of entries displayed by the shortcode. In this case, only the first 10 entries of the form will be displayed.

[vx-entries form-id=1 limit=10 /]

Customizing the columns displayed by the shortcode. Only the columns with labels ‘Name’ and ‘Email’ will be shown.

[vx-entries form-id=1 col-labels="Name,Email" /]

Applying custom CSS classes to the table. The table will have the classes ‘my-custom-class’ and ‘responsive’.

[vx-entries form-id=1 class="my-custom-class responsive" /]

Displaying entries in a paginated format. Only 5 entries will be shown per page.

[vx-entries form-id=1 per-page=5 /]

Displaying entries of a specific user. Only entries submitted by the user with ID 2 will be shown.

[vx-entries form-id=1 user-id=2 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [vx-entries] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('vx-entries', array($this, 'entries_shortcode'));

Shortcode PHP function:

function entries_shortcode($atts){
 
  $form_id='';
  if(!empty($atts['form-id'])){
   $form_id=$atts['form-id'];   
  }
  if(!empty($atts['form-name'])){
  $forms_arr=get_option('vxcf_all_forms',array()); 
  if(is_array($forms_arr) && count($forms_arr)>0){
   foreach($forms_arr as $form_key=>$form_type){
        if(!empty($form_type['forms']) && is_array($form_type['forms']) && count($form_type['forms'])>0){
   foreach($form_type['forms'] as $k=>$v){
   if($v == $atts['form-name']){ 
   $form_id=$form_key.'_'.$k;    
   }
   }
        } 
   }   
  }     
  }
$fields=vxcf_form::get_form_fields($form_id);
$fields['created']=array('name'=>'created','_id'=>'created', 'label'=> __('Created', 'contact-form-entries'));


  $col_end=count($fields);
  if(!empty($atts['cols'])){
   $col_end=(int)$atts['cols'];   
  }  
    $col_start=0;
  if(!empty($atts['col-start'])){
   $col_start=(int)$atts['col-start'];   
  
  }
  
    if(!empty($atts['col-labels'])){
     $col_labels=array_map('trim',array_map('strtolower',explode(',',$atts['col-labels'])));
  
   if(is_array($fields) && count($fields)>0){
    foreach($fields as $k=>$v){ 

      if(isset($v['label'] ) && !in_array( strtolower($v['label']),$col_labels)){
      unset($fields[$k]);    
      }  
    }   
   }   
  }else{
  $fields=array_splice($fields,$col_start,$col_end);    
  } 

vxcf_form::$form_fields=$fields;
    $css='';
    if(!empty($atts['font-size'])){
    // $atts['font-size']='x-small'; 
      $css=' style="font-size: '.esc_attr($atts['font-size']).'"';     
    }
  

      $class='vx_entries_table ';
    if(!empty($atts['class'])){
     $class.=$atts['class'];   
    }
   $class=' class="'.esc_attr($class).'"';   
  
      $table_id='';
    if(!empty($atts['id'])){
   $table_id='id="'.esc_attr($atts['font-size']).'"';   
  }
  //var_dump($fields);
  $limit='20';
    if(!empty($atts['limit'])){
   $limit=(int)$atts['limit'];   
  }  
  $start='0';
    if(!empty($atts['start'])){
   $start=(int)$atts['start'];   
  }
  $search=$export='';
  if($this->do_actions() ){
   if(!empty($atts['search'])){
   $search=$atts['search'];   
  }  
  if(!empty($atts['export'])){
   $form_ids=get_option('vx_crm_forms_ids');
     if(!is_array($form_ids)){ $form_ids=array(); }
     if(!isset($form_ids[$form_id])){
      $form_ids[$form_id]=rand(99999,999999999).uniqid().time().rand(999,9999999).uniqid();  
     update_option('vx_crm_forms_ids',$form_ids); 
     }
   $export=$form_ids[$form_id];   
  } 
  }
    $page_size='3';
    if(!empty($atts['per-page'])){
   $page_size=(int)$atts['per-page'];   
  }  
 $offset=$this->time_offset(); 
  $req=array('start'=>$start,'vx_links'=>'false');
    if(isset($atts['user-id'])){
   $req['user_id']=!empty($atts['user-id']) ? (int)$atts['user-id'] : get_current_user_id();   
  } 
 $data=vxcf_form::get_data_object(); 
$entries=$data->get_entries($form_id,$limit,$req); 
$leads=array();
if(!empty($entries['result'])){
$leads=$entries['result'];    
}

$base_url=vxcf_form::get_base_url();
 if(!empty($atts['sortable'])){
wp_enqueue_script( 'vx-tablesorter-js');
wp_enqueue_script( 'vx-tablewidgets-js');
 if(!empty($atts['pager'])){
wp_enqueue_script( 'vx-tablepager-js');
 }
wp_enqueue_style('vx-tablesorter-css');
 }
 $leads_table=apply_filters('crmperks_entries_template',self::$path . "templates/leads-table.php");
  /* foreach($leads as $lead){

  foreach($fields as $field){  

if($field['name'] == 'time'){
  $field['name']='created';  
}

$field_label='';
if(isset($lead[$field['name']])){
 $field_label=maybe_unserialize($lead[$field['name']]);   

if(is_array($field_label)){ 
  $field_label=implode(', ',$field_label);  
}else if($field['name'] == 'created'){
   $field_label=strtotime($field_label)+$offset;
$field_label= date('M-d-Y H:i:s',$field_label);   
}

}

  }
 
  } die('-----------');*/
  ob_start();
include($leads_table);
return ob_get_clean();
}

Code file location:

contact-form-entries/contact-form-entries/contact-form-entries.php

Conclusion

Now that you’ve learned how to embed the Contact Form Entries Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

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