title: How to make my plugin tabs to display correctly in wordpress/woocommerce using current_user_can()
body: <p>I am a junior dev and also new to stackoverflow. I am working on a plugin and would like to display different tabs on the admin page according to the logged in user (mainly admin and shop manager). My current implementation displays the different tabs as required but there is a problem. Some tabs are displaying empty pages, while others are working correctly. What might be wrong with my code? Thanks as you help me.</p>
  <pre><code>class my_plugin_admin{
  
      public $plugin_tabs = array();
      
      public function __construct() {
          add_action('admin_init', array( $this, 'show_different_tabs' ));
      }
  
      public function show_different_tabs(){
       if(current_user_can('administrator')){
          $this-&gt;plugin_tabs = array(
          'tabname1'=&gt; __('Tabname1' , 'woocommerce-myplugin'),
          'tabname2'=&gt; __('Tabname2' , 'woocommerce-myplugin'),
          'tabname3'=&gt; __('Tabname3' , 'woocommerce-myplugin'),
          'tabname4'=&gt; __('Tabname4' , 'woocommerce-myplugin')
          );
       }elseif(current_user_can('manage_woocommerce')){
         $this-&gt;plugin_tabs = array(
          'tabname1'=&gt; __('Tabname1' , 'woocommerce-myplugin'),
          'tabname2'=&gt; __('Tabname2' , 'woocommerce-myplugin')
           );
     }else{
         $this-&gt;plugin_tabs = array(
          'tabname1'=&gt; __('Tabname1' , 'woocommerce-myplugin'),
          'tabname2'=&gt; __('Tabname2' , 'woocommerce-myplugin')
           );
     }
  }
  } 
  </code></pre>
  <p>There is frontend and backend for this plugin. There are tabs that are interacting with db, one exports file to .csv(this one lis loading infinitely), one shows logs(also this loads infinitely), one loads orders e.t.c(this isn't loading orders but appears to display page, i.e buttons,inputs etc). Also on the frontend there is a foreach that loops threough the tabs like so ...<br />
  <code>&lt;?php foreach ($plugin_tabs as $plugin_tab =&gt; $plugin_tab_translated) {?&gt; &lt;a class=&quot;nav-tab &lt;?php echo $active_tab == $$plugin_tab  ? 'nav-tab-active' : '' ?&gt;&quot; href=&quot;&lt;?php echo admin_url( 'admin.php?page=' . $menu_slug . '&amp;tab=' . $plugin_tab  ) ?&gt;&quot;&gt;&lt;?php echo $plugin_tab _translated ?&gt;&lt;/a&gt; &lt;?php } ?&gt;</code></p>