2017-11-09 10 views
1

アドミニストレーターアカウントがログインしている場合、サブミットジョブステップをバイパスする条件を設定するにはどうすればよいですか?これを行う可能性はありますか?Woocommerceジョブリストのステップから管理者を除外する機能

public static function submit_job_steps($steps) { 
    if (self::get_packages() && apply_filters('wcpl_enable_paid_job_listing_submission', true)) { 
     // We need to hijack the preview submission to redirect to WooCommerce and add a step to select a package. 
     // Add a step to allow the user to choose a package. Comes after preview. 
     $steps['wc-choose-package'] = array(
      'name'  => __('Choose a package', 'wp-job-manager-wc-paid-listings'), 
      'view'  => array(__CLASS__, 'choose_package'), 
      'handler' => array(__CLASS__, 'choose_package_handler'), 
      'priority' => 25, 
     ); 
     // If we instead want to show the package selection FIRST, change the priority and add a new handler. 
     if ('before' === get_option('job_manager_paid_listings_flow')) { 
      $steps['wc-choose-package']['priority'] = 5; 
      $steps['wc-process-package'] = array(
       'name'  => '', 
       'view'  => false, 
       'handler' => array(__CLASS__, 'choose_package_handler'), 
       'priority' => 25, 
      ); 
      // If showing the package step after preview, the preview button text should be changed to show this. 
     } elseif ('before' !== get_option('job_manager_paid_listings_flow')) { 
      add_filter('submit_job_step_preview_submit_text', array(__CLASS__, 'submit_button_text'), 10); 
     } 

     // We should make sure new jobs are pending payment and not published or pending. 
     add_filter('submit_job_post_status', array(__CLASS__, 'submit_job_post_status'), 10, 2); 
    } 
    return $steps; 
} 

答えて

1

これはあなたの関数の先頭にだけ、この行を追加して行うことができます。

if(current_user_can('manage_options')) return $step; 

'manage_options'としての機能は、管理者がログインされたときにのみ、管理者ユーザーの役割のためでありますあなたの関数は処理されずに$stepを返します。

または

if(get_current_user_id() == 'administrator') return $step; 
+0

ありがとうございました! –

関連する問題