试试这个,假设job_posting_access
是某个插件定义的有效挂钩:
add_action( \'job_posting_access\', function() {
// $pages is Page ID, title, slug, or array of these for which access is restricted
$pages = ( array (\'page 1\', 42, \'page-2\') );
if ( ! current_user_can( \'employer\' ) && is_page( $pages ) )
wp_die(\'<div class="job-manager-error">Sorry, you do not have permission to post jobs.</div>\');
}