Grow your CSS skills. Land your dream job.

WordPress is giving a permissions error on plugin submission

  • # March 31, 2013 at 10:42 pm

    I’m creating a new plugin (based on a previous plugin I created that works). The options pages show up fine but when I submit I get the “You do not have sufficient permissions to access this page.” error.

    The plugin it’s based on works and submits fine. I’m not sure why this is having an issue though.

    Below is the script that creates the plugin, it’s pages, and the code that creates the new item on submit.

    add_action( ‘wp_enqueue_scripts’, ‘add_product_focus_styles’ );
    add_action( ‘wp_enqueue_scripts’, ‘add_product_focus_scripts’ );

    function add_product_focus_styles() {
    wp_register_style( ‘pfstyles’, plugins_url(‘/css/product-focus.css’, __FILE__));
    wp_enqueue_style( ‘pfstyles’ );
    }

    function add_product_focus_scripts() {
    //wp_register_script(‘rpjs’,plugins_url(‘/js/productfocus.js’, __FILE__),”,”,true);
    //wp_enqueue_script(‘rpjs’);
    }

    register_activation_hook(__FILE__, ‘product_focus_activate’);

    // activating the default values
    function product_focus_activate(){
    product_focus_start();
    }

    function product_focus_start() {
    global $wpdb;
    /*
    code that creates my table
    */
    }
    /**
    * Add the menu items to the WordPress menu bar
    */
    add_action(‘admin_menu’, ‘create_product_focus_menu_page’);

    function create_product_focus_menu_page() {
    add_menu_page(‘Add Focus’, ‘Add Focus’, ‘administrator’, ‘productfocus/product-focus-create.php’,”, plugins_url(‘productfocus/images/icon.png’));
    add_submenu_page(‘productfocus/product-focus-create.php’, ‘Edit Focus’, ‘Edit Focus’, ‘administrator’, ‘productfocus/product-focus-edit.php’);

    add_action( ‘admin_init’, ‘add_product_focus_styles’ );
    add_action( ‘admin_init’, ‘add_product_focus_scripts’ );
    }

    if(isset($_POST)){
    global $wpdb;
    $table_name = $wpdb->prefix.”productfocus”;

    $pfname = $_POST;
    $pfdate = $_POST;
    $return = $_SERVER;

    $q = $wpdb->prepare(“INSERT INTO $table_name (pfname,pfdate) VALUES (%s,$d,)”,$pfname,$pfdate);
    $wpdb ->query($q);

    header(“location: “.$_SERVER.”?page=productfocus/product-focus-create.php”);
    exit;
    }

    any clues why the “create” page will show but I get the error when I try to submit the form?

    # April 1, 2013 at 12:23 am

    Turns out the name of the button used to submit the page didn’t match in the submit function.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".