Field Visibility

Field Visibility Add-on gives you the possibility 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.

Install the Field Visibility Add-on

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

After purchasing the add-on, the .zip file will be available for download under your account page by clicking the “Add-ons Download” button.

Profile Builder Pro - Account Page - Download Add-ons

Once downloaded, you can install the add-on as a normal WordPress plugin, by uploading the .zip file in your WordPress Admin -> Plugins -> Add New -> Upload Plugin.

Alternatively, you can install the Field Visibility add-on by extracting the folder found inside the archive and uploading the entire folder via FTP to your /wp-content/plugins folder found inside your WordPress install.

Note – For 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:

  • Visibility – Admin Only field is visible only for administrators. User Locked field is visible for both administrators and users, but only administrators have the capability to edit it
  • User Role Visibility – Select which user roles see this field
  • Location Visibility – Select the locations you wish the field to appear

Profile Builder Pro - Field Visibility - Options

Visibility

We can set the Visibility option to:

  • All – The field is seen by the Admin and also by the User
  • Admin Only – The field is visible only by the Admin
  • User Locked field – The field is visible for both the Admin and the User, but only the Admin has the capability to edit it

Profile Builder Pro - Field Visibility - Visibility Options

Setting Visibility to All

This 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 options 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.

Profile Builder Pro - Field Visibility - Admin Only

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.

Profile Builder Pro - Field Visibility - User Locked

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.

Profile Builder Pro - Field Visibility - User Role Visibility

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 thought 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.

Profile Builder Pro - Field Visibility - Location Visibility

The available options are:

  • All – Displays the field in WordPress Edit Profile Form (back-end), Register Forms Front-End and also in Edit Profile Forms Front-End
  • WordPress Edit Profile Form (back-end) – This is the user profile that you can find by going to your Dashboard -> Users and then edit any user
  • Register Forms Front-End – This represents all the Registration forms that are created with Profile Builder
  • Edit Profile Forms Front-End – This represents all the Edit Profile forms created with Profile Builder

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
/*
 * Make field visibility user locked on the Edit Profile page only
 */
 
add_filter( 'wppb_output_display_form_field', 'wppbc_handle_output_display_state', 20, 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