A Cozmoslabs Product

Field Visibility

Field Visibility Add-on gives you the possibility to create User Locked fields or fields which are only visible to the Administrator, it also allows you to show/hide fields on certain forms and you can show/hide fields only for specific User Roles.

This allows you to have a single Edit Profile Form for multiple user roles, for example.

Activating the Field Visibility Add-on

Field Visibility is an Advanced add-on, available with a Profile Builder Basic, Pro, or Agency license only.

After purchasing a premium version of Profile Builder, you can check the following guide on how to install Profile Builder.

After the installation of the Basic, Pro, or Agency version, in order to activate the Field Visibility add-on, go to Dashboard → Profile Builder → Add-ons → Field Visibility Add-on and click activate.

For the Field Visibility add-on to work as expected, you’ll also need to have the following plugin installed and activated on your site:

Field Visibility Options

After we activate the Field Visibility Add-on we will see new options for our Extra Fields Types:

Please keep in mind that the Field Visibility add-on is not compatible with the fields in the “Other” section, so these options will not be displayed for them.

Visibility

We can set the Visibility option to:

Setting Visibility to All

This is the default option and it means that the User and the Admin can both see and edit the field. Inside the User Role Visibility option check “All” to display the field to logged out users.

Setting Visibility to Admin Only

This option means that the field is visible and editable only by Administrators. The values selected inside the User Role Visibility option will not overwrite the “Admin Only” option.

Admin Side

This is how the Admin sees the Registration form.

Profile Builder Pro - Field Visibility - Admin Only - Admin Registration Form

This is how the Admin sees the Edit Profile form.

Profile Builder Pro - Field Visibility - Admin Only - Admin Edit Profile Form

This is how the Admin sees the WordPress Edit Profile form.

Profile Builder Pro - Field Visibility - Admin Only - Admin WordPress Edit Profile Form

User Side

This is how the user sees the Registration form.

Profile Builder Pro - Field Visibility - Admin Only - User Registration Form

This is how the user sees the Edit Profile form.

Profile Builder Pro - Field Visibility - Admin Only - User Edit Profile Form

This is how the user sees the WordPress Edit Profile form.

Profile Builder Pro - Field Visibility - Admin Only - User WordPress Edit Profile Form

Setting Visibility to User Locked

It means that the field is visible for both the Administrator and the User, but only the Administrator will be able to edit it. Check the “All” value inside the User Role Visibility option to display the user locked field to all the user roles.

Admin Side

This is how the Admin sees the Registration form.

Profile Builder Pro - Field Visibility - User Locked - Admin Registration Form

This is how the Admin sees the Edit Profile form.

Profile Builder Pro - Field Visibility - User Locked - Admin Edit Profile Form

This is how the Admin sees the WordPress Edit Profile form.

Profile Builder Pro - Field Visibility - User Locked - Admin WordPress Edit Profile Form

User Side

This is how the user sees the Registration form.

Profile Builder Pro - Field Visibility - Admin Only - User Registration Form

This is how the user sees the Edit Profile form.

Profile Builder Pro - Field Visibility - User Locked - User Edit Profile Form

This is how the user sees the WordPress Edit Profile form.

Profile Builder Pro - Field Visibility - User Locked - User WordPress Edit Profile Form

User Role Visibility

This option gives you the ability to show/hide a field only for certain User Roles.

For example, you might have an Editor and a Subscriber user role, and you want them to be able to update their profile using the same Edit Profile page, but you are requesting different details about them upon registration.

This options allows you to show only the relevant fields to the Editor or Subscriber user roles, even though your form contains all the fields.

Inside the User Role Visibility option check “All” to display the field to logged out users. The values selected inside the User Role Visibility option will not overwrite the “Admin Only” option.

Location Visibility

This option gives you the ability to show the field only in certain forms.

The available options are:

How to

Make a field User Locked only in the Edit Profile form

Lets say that we have a User Locked Select Field but we want to display this field in the Registration Form.

We want to let our users select a value inside the Select field but after the Registration we want this Select field to become a read only field inside the Edit Profile page.

Also, we want only the Admin to be able to modify the value displayed inside the Select Field.

Go to Profile Builder -> Manage Fields -> Add a Select Field and in the Visibility option choose User Locked and for the the User Role Visibility and Location Visibility check the “All” value.

Now you will need to use some custom code in order to make the Select Field User Locked only in the Edit Profile page:

1. Create an empty plugin like this: https://gist.github.com/sareiodata/76f701e01db6685829db

2. Add the following code to the end of it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
 * Checks to see if a user_locked field has values set when saving the form. It should not, and
 * if it does an error is printed for that form, preventing the form values to be saved
 *
 */
function wppbc_fv_check_if_user_locked( $message, $field, $request_data, $form_location, $form_role = '', $user_id = 0 ) {
	// Handle visibility for register form
	if( $form_location == 'register' ) {
 
		// Visibility for User Locked option
		if( !current_user_can( apply_filters( 'wppb_fv_capability_user_locked', 'manage_options' ) ) ) {
			if (isset($field['visibility']) && ($field['visibility'] == 'user_locked')) {
                		remove_filter('wppb_check_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug( $field['field'] ), 'wppb_in_fv_check_field_value', 11);
                        	remove_filter('wppb_check_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug( $field['field'] ), 'wppb_in_fv_check_if_user_locked', 11);
                	}
		}
	}
 
	return $message;
}
 
function wppbc_init_field_visibility() {
 
	if ( !defined('WPPBFV_IN_PLUGIN_DIR') ){
		return;
	}
 
	$filter_fields = wppb_in_field_visibility_get_extra_fields();
	// add filters for the fields
 
	foreach( $filter_fields as $filter_field_slug => $filter_field ) {
		if( class_exists('Wordpress_Creation_Kit_PB') ) {
			add_filter('wppb_check_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug( $filter_field ), 'wppbc_fv_check_if_user_locked', 10, 6);
		}
	}
}
add_action( 'init', 'wppbc_init_field_visibility', 999 );
 
 
/*
 * Make field visibility user locked on the Edit Profile page only
 */
 
add_filter( 'wppb_output_display_form_field', 'wppbc_handle_output_display_state', 999, 5 );
function wppbc_handle_output_display_state( $display_field, $field, $form_location, $form_role, $user_id ){
 
	// Handle visibility for register form
	if( $form_location == 'register' ) {
 
		// Visibility for User Locked option
		if( !current_user_can( apply_filters( 'wppb_fv_capability_user_locked', 'manage_options' ) ) ) {
			if (isset($field['visibility']) && ($field['visibility'] == 'user_locked')) {
				$display_field = true;
			}
		}
	}
	return $display_field;
}

3. Install this plugin via FTP (copy it inside wp-content/plugins) or create a zip archive with it and install it via the WordPress plugin upload functionality

This will work only in Front End and if users have access to the Back End they will be able to modify it. The Admin will be able to modify it in Front End.

Get Field Visibility – Profile Builder Add-on

The Ultimate Membership Bundle

Combine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.

Get 25% off with the bundle

Help & Support

We’re here to help you every step of the way.

Open a Support Ticket