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

1 comment

  1. Two alternatives. You can add an invisible sub menu page, or work with the URL: /wp-admin/options-general.php?page=crud&create=true.

    For this second option, it’s just:

    function crudboard()
    {
        $add_new_url = admin_url('options-general.php?page=crud&create=true');
        ?>
        <div class="wrap">
            <?php if( !isset( $_GET['create'] ) ) { ?>
            <h2>
                Motors
                <a class="add_new-h2" href="<?php echo $add_new_url; ?>">Add New</a>
    
            </h2>
            <table class="wp-list-table widefat fixed pages">
                <tr><td>Start page</td></tr>
            </table>
            <?php } else { 
                include 'create.php';
            } 
    }
    

    And a sample create.php file:

    <?php
    /**
     * Create page
     */
    ?>
    <h2>Add new Motor</h2>
    <table class="wp-list-table widefat fixed pages">
        <tr><td>Create page</td></tr>
    </table>