Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress Error while developing a plugin -"You do not have sufficient permissions to access this page."

Tags:

php

wordpress

I have just started learning wordpress plugin development and got this error when I access the my plugin menu from admin.

Here is the code: importer.php

//*************** Admin function ***************
function oscimp_admin() {
    include('importer_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');

importer_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>

Any one can figure out what I am doing wrong.

like image 611
Avinash Avatar asked Nov 19 '10 10:11

Avinash


People also ask

Why is WordPress not adding new plugins?

The plugins section will not appear on the WordPress dashboard if you don't have the Administrator role. If the website's owner asks you to edit or install a plugin, you need to ask to increase your user role. You can find the name of the administrator at WordPress Users > All Users Menu.

How do I check my WordPress plugins error?

Once you've installed the plugin, go to the Dashboard and enable the “PHP Error Log” widget through the “Screen Options” panel. The widget should automatically display the last 20 lines from your PHP error log.

Why am I getting a WordPress error?

It's usually due to a glitch in the server's connection with your WordPress files, incorrect file permissions (which we discussed earlier), or an unreliable internet connection. If WordPress fails to auto-update, you may be hit with the WSoD, or notice warning errors when you try to access your site.


1 Answers

The problem is fourth parameter. I have removed the spaces from the fourth parameter with _ and it works.

Thanks for your help...

like image 152
Avinash Avatar answered Sep 20 '22 13:09

Avinash