I’m developing my first WordPress plugin, and I have one line which deletes an entry. I have to use query string parameters to pass in the action and the object id. My code is:
$pageText .= '<td><a href="'.$_SERVER['REQUEST_URI'].'?useraction=delete&domainid='.$file.'">Delete</a></td></tr>';
This creates a ‘delete’ link and populates the two parameters. Problem is, WordPress gives me a “You do not have sufficient permissions to access this page.” for passing in a variable in the query string.
Does anyone know how to properly pass variables in a plugin?
I don’t think that is the problem. I’d rather bet that by building the URL that way, you are dropping other request parameters (that are not preserved in REQUEST_URI) that you need to add again. To re-build the complete query string, the cleanest way would be using
http_build_query():The http_build_query (it is a bit hard to read) merges an array with your URL parameters, and the existing $_GET array together into a proper query string.