Skip to content
WPForms Views
  • Features
  • ProductsExpand
    • Views for WPForms
    • Charts for WPForms
    • WPForms Import Entries
  • Pricing
  • Demo
  • Blog
  • SupportExpand
    • Docs
    • Contact Us
Login
Account
Get Views
WPForms Views

Getting Started

10
  • How to Install WPForms Views Plugin
  • How to upgrade your WPForms Views License
  • How to Add Views for WPForms License Key
  • How to Create Table View of WPForms Entries
  • How to Create a DataTable view of WPForms Entries in Frontend
  • How to Create List View of WPForms Entries
  • How to Design & Style Your WPForms View
  • How to hide empty fields in WPForms Views
  • How to use WPForms Smart Tags in Custom HTML field
  • How to Clone or Duplicate Form Entries in WPForms Views

Edit Entries

4
  • How to edit WPForms Entries from Frontend
  • How to Hide Form fields when editing entries
  • How to Unapprove Entry after Editing
  • How to send Email Notification after Editing Entry

Filter & Sort

7
  • How to Configure the Search Form
  • How to Filter WPForms Entries by Field Value
  • Sort WPForms Entries by Field Value
  • How to use Merge Tags to Filter WPForms Entries
  • How to Display only WPForms Starred Entries in Frontend
  • How to Display Only User Submitted Entries in WPForms
  • How to Display only Viewed WPForms Entries

Single Entry

1
  • How to Display WPForms Entry details on Single Page

Calculations

2
  • How to display WPForms Field Calculations in table footer
  • How to Display Field Calculations in Your View

Inline Edit

2
  • How to setup Inline Edit for WPForms Views
  • How to send Email Notification after Editing Entry using Inline Edit Add-on

Approve Entries

1
  • How to Show Only Approved WPForms Entries

Delete Entries

1
  • How to allow users to delete WPForms Entries from frontend

Google Maps

1
  • How to use Google Maps addon to display maps in view

Hooks & Filters

1
  • Code Examples

Import Entries

1
  • How to Import Entries into WPForms

Charts for WPForms

1
  • Getting Started With Charts for WPForms
View Categories
  • Home
  • Docs
  • Hooks & Filters
  • Code Examples

Code Examples

Image
Aman
Updated on December 13, 2024

2 min read

# Display Single Entry Page to only logged-in users #

add_filter( 'wpf_views_shortcode_content','seji_maybe_display_single_entry', 20, 3 );

function seji_maybe_display_single_entry($content, $view_id, $view_settings){
	$entry_id = get_query_var( 'entry');
	if ( ! empty( $entry_id ) && isset( $_GET['view_id'] ) && ( $view_id == $_GET['view_id'] )) {
		if( is_user_logged_in( ) ){
			return $content;
		}else{
			return 'Please login to view entry details';
		}
	}
	return $content;
}

# Add custom class name to View Table #

<?php 

add_filter( 'wpforms_view_table_classes',  'wpf_add_custom_table_classname', 10, 3 );


function wpf_add_custom_table_classname ( $classnames, $view_id, $view_settings ) {

if( $view_id == 'VIEW-ID'){  //  Update VIEW-ID with your View ID
   $classnames .= ' custom-classname';   //  Update your Classname here
}

return $classnames;

}

# Hide characters from field value in View #

<?php
//  Update FIELD-TYPE with your field type e.g name, email, phone etc

add_filter( "wpf-views/FIELD-TYPE-value", 'wh_update_field_display_value', 8, 5 );


function wh_update_field_display_value( $field_value, $_view_field_id, $entry, $_view_settings, $view_Obj ) {
	$view_id = $view_Obj->view_id;
	$_view_field = $_view_settings->fields->{$_view_field_id};
	$form_field_id = $_view_field->formFieldId;


//  Update VIEW-ID with your View ID
//  Update FORM-FIELD-ID with your Field ID

	if ( $view_id == 'VIEW-ID' && $form_field_id == 'FORM-FIELD-ID' ) { 

		if ( ! empty( $field_value ) ) {
           // This adds xxxxx after first 3 characters in field value
			$field_value = substr( $field_value, 0, 3 ) . 'xxxxx';
		}
	}

	return $field_value;
}

# Prefill search Field in View #

<?php
add_filter( 'wpf_views_search_field_value', 'wh_views_search_field_value', 10, 4 );

function wh_views_search_field_value(  $value, $search_field, $_view_settings, $view_Obj ) {
	$view_id = $view_Obj->view_id;
	$field_id = $search_field->fieldId;

    //  Update VIEW-ID with your View ID
    //  Update FIELD-ID with your Field ID

	if ( $view_id  === 'VIEW-ID' && $field_id === 'FIELD-ID' ) {

		$value = get_user_meta(get_current_user_id(), 'gender', true);
	}
	return $value;
}

Code ExamplesCode Examples
Table of Contents
  • # Display Single Entry Page to only logged-in users
  • # Add custom class name to View Table
  • # Hide characters from field value in View
  • # Prefill search Field in View

Views for WPForms

Drag & Drop View builder for WPForms.

We build scalable, intelligent and professional web apps to simplify lives of different businesses and people since 2010.

Our Other WordPress Plugins

Views for Ninja Forms

Views for Contact Form 7

Sitemap

  • Home
  • Features
  • Pricing
  • Blog
  • Inline Entry Editing
  • WPForms Import Entries Add-on
  • Charts for WPForms
  • Documentation
  • Changelog

Company

  • My Account
  • FAQs
  • Terms & Conditions
  • Cancellation & Refund Policy
  • Privacy Policy
  • Sitemap
  • Contact Us

We Accept All Major Credit Cards For Fast And Easy Payment

Image

© 2026 WPForms Views

Facebook X YouTube

Disclaimer: Views for WPForms is an independent third-party plugin developed by WEBHOLICS. It is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WPForms or its parent company. All product names, logos, and brands are property of their respective owners.

  • Features
  • Products
    • Views for WPForms
    • Charts for WPForms
    • WPForms Import Entries
  • Pricing
  • Demo
  • Blog
  • Support
    • Docs
    • Contact Us
Advertisement