diff --git a/includes/admin/class-wp-job-manager-settings.php b/includes/admin/class-wp-job-manager-settings.php index 9a38516f4..07adcc29c 100644 --- a/includes/admin/class-wp-job-manager-settings.php +++ b/includes/admin/class-wp-job-manager-settings.php @@ -624,6 +624,16 @@ protected function init_settings() { 'desc' => sprintf( __( 'Enter which roles or capabilities allow visitors to view a single job listing. If no value is selected, everyone (including logged out guests) will be able to view job listings.', 'wp-job-manager' ), 'http://codex.wordpress.org/Roles_and_Capabilities' ), 'track' => 'bool', ], + [ + 'name' => 'job_manager_submit_job_listing_capability', + 'std' => [], + 'label' => __( 'Submit Job Capability', 'wp-job-manager' ), + 'type' => 'capabilities', + 'sanitize_callback' => [ $this, 'sanitize_capabilities' ], + // translators: Placeholder %s is the url to the WordPress core documentation for capabilities and roles. + 'desc' => sprintf( __( 'Enter which roles or capabilities allow visitors to submit a job listing. If no value is selected, everyone (including logged out guests) will be able to submit job listings.', 'wp-job-manager' ), 'http://codex.wordpress.org/Roles_and_Capabilities' ), + 'track' => 'bool', + ], ], ], ] diff --git a/templates/access-denied-submit-job_listing.php b/templates/access-denied-submit-job_listing.php new file mode 100644 index 000000000..c60e7bd25 --- /dev/null +++ b/templates/access-denied-submit-job_listing.php @@ -0,0 +1,20 @@ + + +

diff --git a/templates/job-submit.php b/templates/job-submit.php index 2dea23117..d92e80f62 100644 --- a/templates/job-submit.php +++ b/templates/job-submit.php @@ -8,7 +8,7 @@ * @author Automattic * @package wp-job-manager * @category Template - * @version 1.34.3 + * @version $$next_version$$ */ if ( ! defined( 'ABSPATH' ) ) { @@ -17,46 +17,30 @@ global $job_manager; $captcha_version = WP_Job_Manager\WP_Job_Manager_Recaptcha::instance()->get_recaptcha_version(); -?> -
- ' . esc_html__( "You are editing an existing job. %s", 'wp-job-manager' ) . '

', '' . esc_html__( 'Create A New Job', 'wp-job-manager' ) . '' ); - } - ?> +if ( job_manager_user_can_view_submit_job_listing() ) : ?> + - + ' . esc_html__( "You are editing an existing job. %s", 'wp-job-manager' ) . '

', '' . esc_html__( 'Create A New Job', 'wp-job-manager' ) . '' ); + } + ?> - + - + - + - - - - - - $field ) : ?> -
- -
- $key, 'field' => $field ] ); ?> -
-
- - - + - - -

+ - + + - $field ) : ?> + $field ) : ?>
@@ -65,28 +49,48 @@
- - + - + + +

-

- - - - value="" /> - '; - } - ?> - -

+ - + $field ) : ?> +
+ +
+ $key, 'field' => $field ] ); ?> +
+
+ - + + - -
+ + +

+ + + + value="" /> + '; + } + ?> + +

+ + + + + + + + + + \ No newline at end of file diff --git a/wp-job-manager-functions.php b/wp-job-manager-functions.php index 05fe8b537..337b6db5f 100644 --- a/wp-job-manager-functions.php +++ b/wp-job-manager-functions.php @@ -1745,7 +1745,7 @@ function job_manager_count_user_job_listings( $user_id = 0 ) { } /** - * True if an the user can browse resumes. + * True if an the user can browse job listings. * * @return bool */ @@ -1774,7 +1774,7 @@ function job_manager_user_can_browse_job_listings() { } /** - * True if an the user can view a resume. + * True if an the user can view a job listing. * * @since 1.37.0 * @@ -1817,6 +1817,37 @@ function job_manager_user_can_view_job_listing( $job_id ) { return apply_filters( 'job_manager_user_can_view_job', $can_view, $job_id ); } +/** + * True if an the user can view submit job listing. + * + * @since $$next_version$$ + * + * @return bool + */ +function job_manager_user_can_view_submit_job_listing() { + $can_view = true; + $caps = get_option( 'job_manager_submit_job_listing_capability' ); + + if ( $caps ) { + $can_view = false; + foreach ( $caps as $cap ) { + if ( current_user_can( $cap ) ) { + $can_view = true; + break; + } + } + } + + /** + * Filter if the current user can or cannot view job submission + * + * @since $$next_version$$ + * + * @param boolean $can_view + */ + return apply_filters( 'job_manager_user_can_view_submit_job', $can_view ); +} + /** * Return an associative array containing the options for salary units, based on Google Structured Data documentation. *