• Hello,

    I am working on a project where I have entries from a database that I would like to allow to be edited from the Admin section of my site. That area is fine I have created a custom options page in the Admin section for my plugin and I have pulled the data from the database.

    My problem though is I would like to create an “Edit” link next to each entry to open a new page in the admin area that is filled with only the information from that entry. I have tried creating a link using “…../wp-admin/admin.php?page=(LINK TO PLUGIN FILE OR A FUNCTION NAME)” but I keep getting “You do not have sufficient permissions to access this page.”

    Is there something I am missing or maybe an easier way of doing this? Thank you in advance…

Viewing 1 replies (of 1 total)
  • Thread Starter BenjaminRMueller

    (@benjaminrmueller)

    I ended up finding the answer while searching through tutorials and in case anyone needs the answer I thought I would throw it in here (I hate when people find an answer to something on a forum but never post the answer haha)

    What I ended up doing is just using GET to pull the page from the URL and then recreated the link and just added the variable information I need to pass.

    Since code speaks louder then words in the development community here is an excerpt from my code…

    $id = $_GET['id'];
    
    $table_name = $wpdb->prefix . "INPUT TABLE NAME HERE";
    
    if (!empty($id)) {
    $query = $wpdb->get_results("SELECT * FROM $table_name WHERE id='$id'");
    } else {
    $query = $wpdb->get_results("SELECT * FROM $table_name");
    }
    
    foreach ($query as $the_item) {
    print '<a href="?page=' . $_GET['page'] . '&id=' . $the_item->id . '">Edit</a>';
    }

    The id field is dynamically filled from the database query and once that “Edit” link has been clicked it pulls only the information for that entry. From here I can now manipulate only that entry’s data and configure it any which way I desire.

    If anyone has any suggestions on a better way to do this or questions for that matter just let me know.

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Creating a Edit Link in the Admin Section’ is closed to new replies.