Applications: Limiting applications to a certain role

A common request is to limit the actual application form to a certain user role. This is possible with a small amount of customisation, as follows:

↑ Back to Top 1. Override the Template File

Copy the plugin file wp-job-manager-applications/templates/application-form.php to YOURTHEME/wp-job-manager-applications/application-form.php. The version you copy to your theme will take priority.

↑ Back to Top 2. Edit the Template File

Inside your newly copied file, you can use the current_user_can function to check if a user can apply.

At the top of the file add:

<?php if ( current_user_can( 'ROLE' ) ) : ?>

Replace ROLE with your desired role or capability, for example, ‘subscriber’.

At the end of the file add:

<?php else : ?>
Custom content here shown to users without access.
<?php endif; ?>

The application form will now only be visible to the users with permission.

Note: According to the WordPress codex on the current_user_can function, “While checking against particular roles in place of a capability is supported in part, this practice is discouraged as it may produce unreliable results.”, so we cannot guarantee that this custom code will always work as expected.