You do not have sufficient permissions to access this page while making a plugin

You do not have sufficient permissions to access this page. This is the error i am facing while making my own plugin.Actually, i want to link to another page.

WordPress version is 3.8.1
I made a plugin that shows the following display(the index page of my crud plugin)
enter image description here

Read More

I want the Add New link to redirect to other create.php(which is in the same folder as crud.php the index php file).But it says You do not have sufficient permissions to access this page.
Is it correct the way i link to create.php file inside my plugin folder?
I tried to read abt cross page call in wordpress but no luck.
I tried different plugin video tutorial every video ends in the same page.
I want to be redirected to the create.php page with the same sidebar and topbar in crud page.
And of course i have nicely embeded the html code and php code it’s just i did not know the way to show them nicely here.
I want a redirect to prevent from inserting data to my table everytime the page is refreshed.
And my folder struncture is as follows

enter image description here

The code is as follows

add_action('admin_menu','crudindex');
function crudindex(){
    add_options_page('Crud Dashboard', 'Crudboard', 'manage_options', 'crud', 'crudboard');
}

function crudboard()
{
    <div class="wrap">
        <h2>
            Motors
            <a class="add_new-h2" href="<?php bloginfo('url');?>/wp-admin/options-general.php?page=create">Add New</a>

        </h2>
        <table class="wp-list-table widefat fixed pages">
        </table>
}

I know this is a repeat question.I post it beacause i didn’t find the correct answer.
Thanks

Related posts

Leave a Reply

2 comments

  1. Try

    function crudindex(){
       add_options_page('Crud Dashboard', 'Crudboard', 'manage_options', 'crud', 'crudboard');
       add_options_page(NULL, 'Crudboard', 'manage_options', 'create_crud', 'crudboard');
    }
    

    and your anchor tag like

    <a class="add_new-h2" href="<?php bloginfo('url');?>/wp-admin/options-general.php?page=create_crud">Add New</a>
    
  2. Another way you can do that

    function crudindex(){
       add_options_page('Crud Dashboard', 'Crudboard', 'manage_options', 'crud', 'crudboard');
       add_options_page('Crudboard', 'Crudboard', 'manage_options', 'create_crud', 'crudboard');
    }
    
    
    function remove_submenus() {
       global $submenu;
       echo "<pre>" . print_r($submenu['options-general.php'], true) . "</pre>";
       unset($submenu['options-general.php'][your-menu-array-key]);
    }
    add_action('admin_menu', 'remove_submenus');
    

    Above will show all sub navigation under settings you find your menu position key and replace with your-menu-array-key