# 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;
}