“You do not have sufficient permissions to access this page” upon accessing my newly created plugin page

I am following “Write your own plugin tutorial” and I made it, activated it, added it to settings to have it’s own plugin page but upon trying to access that plugin page I get above message saying that “I do not have sufficient permissions to access this page” even though I am logged in as admin and I did chmod -R 777 to wordpress directory??

What else could it go wrong?

Read More

Plugin code follows:

oscommerce_importer.php

<?php  
    /* 
    Plugin Name: OSCommerce Product Display 
    Plugin URI: http://www.orangecreative.net 
    Description: Plugin for displaying products from an OSCommerce shopping cart database 
    Author: C. Lupu 
    Version: 1.0 
    Author URI: http://www.orangecreative.net 
    */  

    function oscimp_admin() {  
     include('oscommerce_import_admin.php');  
}  

    function oscimp_admin_actions() {  
      add_options_page("OSCommerce Product Display", "OSCommerce Product Display", 1, "OSCommerce Product Display", "oscimp_admin");  
    }  

    add_action('admin_menu', 'oscimp_admin_actions');  


?>

oscommerce_import_admin.php

 <div class="wrap">  
  <?php    echo "<h2>" . __( 'OSCommerce Product Display Options', 'oscimp_trdom' ) . "</h2>"; ?>  

  <form name="oscimp_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">  
      <input type="hidden" name="oscimp_hidden" value="Y">  
      <?php    echo "<h4>" . __( 'OSCommerce Database Settings', 'oscimp_trdom' ) . "</h4>"; ?>  
      <p><?php _e("Database host: " ); ?><input type="text" name="oscimp_dbhost" value="<?php echo $dbhost; ?>" size="20"><?php _e(" ex: localhost" ); ?></p>  
      <p><?php _e("Database name: " ); ?><input type="text" name="oscimp_dbname" value="<?php echo $dbname; ?>" size="20"><?php _e(" ex: oscommerce_shop" ); ?></p>  
      <p><?php _e("Database user: " ); ?><input type="text" name="oscimp_dbuser" value="<?php echo $dbuser; ?>" size="20"><?php _e(" ex: root" ); ?></p>  
      <p><?php _e("Database password: " ); ?><input type="text" name="oscimp_dbpwd" value="<?php echo $dbpwd; ?>" size="20"><?php _e(" ex: secretpassword" ); ?></p>  
      <hr />  
      <?php    echo "<h4>" . __( 'OSCommerce Store Settings', 'oscimp_trdom' ) . "</h4>"; ?>  
      <p><?php _e("Store URL: " ); ?><input type="text" name="oscimp_store_url" value="<?php echo $store_url; ?>" size="20"><?php _e(" ex: http://www.yourstore.com/" ); ?></p>  
      <p><?php _e("Product image folder: " ); ?><input type="text" name="oscimp_prod_img_folder" value="<?php echo $prod_img_folder; ?>" size="20"><?php _e(" ex: http://www.yourstore.com/images/" ); ?></p>  

      <p class="submit">  
      <input type="submit" name="Submit" value="<?php _e('Update Options', 'oscimp_trdom' ) ?>" />  
      </p>  
  </form>  
 </div>  

Thanks

Related posts

Leave a Reply

1 comment

  1. add_options_page("OSCommerce Product Display", "OSCommerce Product Display", 1, "OSCommerce Product Display", "oscimp_admin");

    should be

    add_options_page( 'OSCommerce Product Display', 'OSCommerce Product Display', 'administrator', 'os_commerce_display_main', 'oscimp_admin' );

    Solution is untested. Docs: Roles and Capabilities, add_options_page

    The 3rd parameter is capability, not user level or whatever you were thinking. I set it to admin, see the docs on roles and capabilities if you want that setup differently. The other error you made was having spaces in your menu slug, it might have worked that way, but it can create a mess. You should also take a very thorough look at the WordPress Coding Standards if you want to do plugin development.