A Cozmoslabs Product

Files Restriction

Files Restriction Add-On allows you to restrict access to files in the WordPress Media Library and to files uploaded through Profile Builder’s Upload Field, based on user roles and login status. This ensures that sensitive files are only accessible to authorized users.

Activating the Files Restriction Add-on

Files Restriction Add-on is available only with a Profile Builder Pro, or Agency license.

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 Pro, or Agency version, in order to activate the File Restriction Add-on, go to Dashboard → Profile Builder → Add-ons → File Restriction Add-on and click activate.

Settings

After you install and activate the Files Restriction add-on, you will have two major functionalities:

  1. You can protect your files within your Media Library.
  2. You can protect files uploaded through Profile Builder upload fields.

Restricting files

Files Restriction Settings are available under Profile Builder → Settings → Content Restriction.

These settings allow you to choose to protect all files in the Media Library, regardless of their type, or only specific file types.

File Restriction Addon Settings

Web Server

File Restriction Web Server Setting

This is an informational field only. It displays the current web server in use.

Protect All File Types

File Restriction Protect All File Types setting

When enabled, all files in the WordPress Media Library, regardless of their type, will be subject to access restrictions based on the Content Restriction settings on the file attachment page.

Additionally, the Protected File Types field will be disabled, and the options specified there will not be taken into account.

File Restriction Protect File Types setting

When disabled, only the file types specified in Protected File Types will be subject to access restrictions. Any other file type not included in the selected types will not be subject to these restrictions.

NOTE: This option may cause performance issues in large Media Libraries due to the high volume of files being processed.

Protected File Types

File Restriction Protect File Types setting only

You can use this option to specify which types of files from the WordPress Media Library will be subject to access restrictions based on the Content Restriction settings on their respective file attachment pages.

This option is available when Protect All File Types is disabled.

There is a list of file types selected by default. You can change this selection by removing a file type from the list or choosing a new one from the drop-down menu. If you want to add a file type to the restricted list but can’t find it in the drop-down, you can type the desired file extension and press Enter key.

Nginx Configuration

File Restriction Nginx Configuration setting

This option is visible only when Nginx web server is in use.

You’ll notice an Nginx include directive and a brief description of the steps required for the file restriction rules to take effect, ensuring this feature works properly.

More detailed information about the required steps under Server Side Configurations → Nginx.

How to restrict access to files

After you have selected which file types to protect, you will need to establish Content Restriction rules that determine whether files can or cannot be accessed.

Profile Builder Content Restriction meta-box

You can manage the Content Restriction rules by navigating to Media -> Library, opening the desired file, clicking on “Edit more details” in the sidebar on the right, and scrolling down to the Profile Builder Content Restriction meta-box where you can set restrictions as needed.

Learn more about Profile Builder Content Restriction meta-box settings.

Upload Field Restriction Settings

Upload Field Restriction Settings are available under Profile Builder → Settings → Advanced Settings → Fields.

File Restriction Addon Upload Field Settings

These settings allow you to restrict access to files uploaded through Profile Builder Forms based on user roles and login status.

Learn more about Profile Builder Upload Field.

Restrict Uploaded Files

By enabling this option, files uploaded through the Upload Fields in Profile Builder forms will be accessible only to logged-in users.

Also, when this option is enabled, you will see that the Restricted Upload Fields and Restrict Files to User Roles options become available.

Restricted Upload Fields

File Restriction Addon Restrict Upload Fields Settings

This option allows you to select which Upload Fields will be used for applying the restriction settings when the file is uploaded.

Option available when Restrict Uploaded Files is enabled.

Restriction settings apply only to files uploaded via selected fields. If a field is not in the selected list, restriction settings will not apply.

If the Restricted Upload Fields option is left empty, restriction settings will apply to files uploaded via any Upload Field used in Profile Builder forms.

Restrict Files to User Roles

File Restriction Addon Restrict File to User Roles setting

This option allows you to specify which User Roles will have access to the uploaded files.

Option available when Restrict Uploaded Files is enabled.

Access to the uploaded files will be restricted to users assigned one or more of the specified User Roles from the list. Users not assigned any of these roles will be unable to access the uploaded file.

If the Restrict Files to User Roles option is left empty, users only need to be logged in to access the file. No specific user role is required.

Server Side Configurations

To ensure the File Restriction Add-on functions correctly and updates the restriction rules accurately, additional steps may be necessary based on the web server being used (Apache or Nginx).

Apache

When the Apache web server is in use, no additional setup or configuration is required.

The necessary directive is automatically inserted into the .htaccess file and updated whenever the File Restriction Settings are changed or the File Restriction Add-on is activated or deactivated.

Nginx

When the Nginx web server is in use, additional steps are required to ensure proper functionality of the File Restriction Add-on.

The additional steps — Insert Nginx Directive and Restart Nginx Web Server — can be performed either Using Web-based Control Panels or Using the Terminal.

Both Web-based Control Panels and the Terminal provide effective means to manage Nginx configurations and restart the server. The choice between these methods often depends on your familiarity with the tools, the complexity of the changes you need to make, and the specific features offered by your hosting environment or server setup.

1. Insert Nginx Directive

This action only needs to be performed once. After the directive is inserted, there is no need to modify or add it again.

2. Restart Nginx Web Server

NOTE: The Nginx web server must be restarted whenever changes are made to the File Restriction Settings or when activating/deactivating the File Restriction Add-on.

File Restriction Nginx notice message

A notification will appear on the WordPress Dashboard whenever the Nginx web server requires a restart. If this notification is dismissed without restarting the web server, it will not reappear until necessary changes are made and the web server needs to be restarted again.

Using Web-based Control Panels

1. Access the Control Panel

Log in to your server’s control panel. Common control panels include:

2. Edit Nginx Configurations

Navigate to the appropriate section or menu within the control panel to edit Nginx configurations. Typically found under domain or server settings.

Look for options labeled Nginx Settings or Web Server Configuration.

Add or modify directives as needed directly within the interface.

3. Save Changes

After adding directives, save the changes through the control panel’s interface. Usually involves clicking a Save or Apply Changes button.

4. Restart Nginx

Some control panels offer the ability to restart Nginx directly from the interface.

Look for a button labeled Restart Server or Apply Configuration. Clicking this will restart Nginx and apply your new configuration.

Using the Terminal

1. Access the Terminal

SSH Access: Open a terminal on your local machine (Windows users may use tools like PuTTY or Windows Subsystem for Linux).

Replace username with your server username and server_ip_address with your server’s IP address or domain name.

2. Edit Nginx Configurations

Navigate to the Nginx configuration directory. For example:

Use a text editor like nano, vim, or emacs to edit the Nginx configuration file (nginx.conf or other relevant files).

Add your directive in the appropriate location within the configuration file. For example:

# Profile Builder PRO: File Restriction 
                    include /mnt/supserv_sites_folder/sites/yourwebiste.com/files/wp-content/plugins/profile-builder-pro/add-ons-advanced/file-restriction/includes/file-restriction-nginx.conf;
You can find your website-specific Nginx include directive at Profile Builder → Settings → Content Restriction → Nginx Configuration.

3. Save Changes

Save the file and exit the text editor (Ctrl+X, then Y to confirm changes in nano).

4. Check Configuration

Validate the Nginx configuration for syntax errors before restarting:

If errors are found, correct them in the configuration file.

5. Restart Nginx

Once the configuration is validated, restart Nginx to apply the changes:

On some systems, you may use service instead of systemctl:

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