0

it's the first time I'm writing a plugin. So far, it creates a table in database on activation, users can add entries to database and they can check saved entries.

I've added Edit and Delete links where I pass the id, but I don't want to edit entries on a different page. How to do it so it's on the same "environment"? Make it something like Users in WordPress, that kind of functionality?

  • What did you try so far ? – Sumit Feb 19 '16 at 4:44
  • It makes database table on activation and deletes it on delete, it has menu where you can see all the records created so far and a submenu item where you can add a new record that gets saved to database. Now I don't know how to edit records using the plugin development logic. – ivanacorovic Feb 19 '16 at 7:28
  • Okay! When you are listing result make link on items. e.g. site/edit-record?id=x edit-record will be your new page and on this page you will get record ID. Populate it then update it on save. Does it make sense ? – Sumit Feb 19 '16 at 8:34
  • Yes, I did something similar with edit.php?id=x. The thing is, my edit.php page is independent, it's just the edit form, it doesn't look like a part of dashboard. – ivanacorovic Feb 19 '16 at 10:00
0

I've managed to do it, but probably there is a much cleaner WP way of doing these things.

So, I have a menu page that I've added using add_menu_page. On it, I display all the records. The url is:

/wp-admin/admin.php?page=plugin-settings (or whatever you call it)

I use:

<a href="<?php echo bloginfo('url');?>/wp-admin/admin.php?page=utm-user-plugin-settings&id=<?php echo $row->id; ?>">Edit</a>

So basically, I ended up using the same page for my EDIT action by checking if $_GET["id"] is set or not.

Again, there is probably a better way to do this, I just don't know it yet, so this will do for now.

  • I am also stucked in same problem & this solution is not working for me. I am getting this error. "You do not have sufficient permissions to access this page." – Adi Oct 25 '16 at 5:57
  • Where exactly do you get this message? When you click edit or...? – ivanacorovic Nov 9 '16 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.