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?

Plugin code follows:


    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() {  

    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');  



 <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' ) ?>" />  


  • Does wordpress give you the error, or does the server? – mor7ifer Jan 20 '12 at 19:41
  • Wordpress does it. I tried on couple of servers, same message. Wordpress version 3.3.1 – daniel trifunovic Jan 20 '12 at 19:48
  • Alright, well then it's a wordpress error, have you cleared all your caches and everything (namely DB caches)? Can you post some code (probably something about current_user_can()) or a link to the plugin, there's a LOT of write your own plugin tutorials... – mor7ifer Jan 20 '12 at 19:51
  • Added plugin code to the post above. I made new installation of Wordpress, new database, but no luck. – daniel trifunovic Jan 20 '12 at 19:53
  • How do you clean those caches? Do you think it might be something interfering in that PHP code?? – daniel trifunovic Jan 20 '12 at 20:02

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.

  • We did it man!! Thanks ;) Will make use of everything you mentioned. – daniel trifunovic Jan 20 '12 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.