WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Passing variable through URL of admin page (2 posts)

  1. sommernyte
    Member
    Posted 3 years ago #

    I am working on a custom plugin. I've created a top level admin menu item and that page all works. It shows all members from my database, is paginated and has a search feature.

    When you click on any member's name, you then go to a sub-page, which is the edit the record. The id of the record is passed through the URL and I retrieve it by setting a variable to $_GET["id"]. Easy enough. I have verified that the variable is accessible from the new page by echoing it on the new page.

    For some reason, however, once I run my variables through a function, I can't retrieve them outside the function. They are declared as global within the function.

    Even more odd, if I make the edit member screen a js pop-up called from the main plugin screen (where I'm simply pulling up member.php?id=0), the whole thing works! But once it gets called as its own page within the admin interface (with the id passed through the variable), it no longer works. :(

    This is probably so simple and so stupid, but I am so stuck!! Please help... I have never made a plugin before and I'm thinking (hoping?) it's something straightforward that I just don't know about.

    I hope this made enough sense to get some sort of help. Don't to bore you with code. :)

  2. Natalya Murphy
    Member
    Posted 2 years ago #

    I had a similar problem and resolved it by changing the "?" to a "&" in the URL. When you access the page from the admin menu, your custom parameter is actually the SECOND variable that gets passed, so you would use the "&" to append it to the URL instead of the "?"

    WRONG:
    http://www.mysite.com/wp-admin/admin.php?page=member?id=0

    RIGHT:
    http://www.mysite.com/wp-admin/admin.php?page=member&id=0

Topic Closed

This topic has been closed to new replies.

About this Topic