I am currently trying to develop a simple wordpress plugin for a client, but am having issues with how complicated wordpress makes its APIs and plugins.

The code so far:


            function pagePluginMenu() {

                $appName = 'Page Rebrander';
                $appID = 'page-rebrander';
                add_menu_page($appName,$appName, 'administrator', $appID . '-top-level', 'pluginAdminScreen');

            function pluginAdminScreen() {
                $data = '<textarea rows="50" cols="100">.......... Text text #YOURSITE.COM# text Text .......... #COMPANY&ADDRESS#';

                echo'<form><p>#YOURSITE.COM#\'s (ie, YourSite.com)</p>';
                echo'<input type="text" name="Website" id="Website" value="#YOURSITE.COM#">';
                echo'<p>Company Name & Address</p>';
                echo'<textarea rows="4" cols="50" name="Address" id="Address">Your Company Name
            & Address Go Here

                if($_POST['Rebrand']) {
                    echo $data;
                } else {
                    echo $data;
            echo'<br/><br/><input type="submit" value="Rebrand"></form>';

I am currently trying to make a simple page. The page displays fine (I am very fluent with PHP so I am trying to use it as much as possible, especially since I don't really need wordpress data to save or anything).

All I want it to do is to take a page's data ($data) and replace two parts in it, the #YOURSITE.COM# and #COMPANY&ADDRESS#.

It takes data from two fields a person puts info in, Website (where they put their website address in (like Your Site.com), and Address (where they put their business name & address in).

The user simply clicks rebrand and it replaces the text with what the user put it, makes things quicker for a user.

However, it keeps telling me I don't have access to admin.php and what not when I click the rebrand button. I believe it has to do with the fact that I am using a form in Wordpress as a plugin however it's easy that way and I don't need a lot of functionality just simply replace the data and display it for the user.

Am I doing something wrong? I am having difficulties understanding wordpress's structure, I have grown accustomed to PHP and how simple I personally find it. I can do this in PHP in minutes but not wordpress, however I want to make it a wordpress plugin.

Thanks in advance!

PS: This site does not allow me to use the appropriate tags, sorry.

Edit: their may be a typo somewhere in the code as I reduced the code from what it originally was to reduce clutter for this post.

1 Answer 1


There are two issues with what your form is currently trying to do:

  1. action="page-rebrander.php" is meaningless to WP (if you actually do have such custom file — you shouldn't). In WP mechanics you should be typically submitting form to the page itself, options.php (for Settings API), or admin-post.php (for more generic forms).

  2. You are trying to pass data with GET request, but really WP considers anything in URL as something you have meant for it. You should stick with POST for passing data most of the time.

  • That definitely helps a bit, changed it to $_POST and now I know action is useless in WP. So how do I get this to pass data when I click the Rebrand button? I only have page-rebrander.php, just added an options.php but it doesn't exactly help atm since I don't know how to use it. Edit: was looking around at other websites but can't find out how to actually get it to work.
    – Jesse J.
    May 26, 2015 at 20:33
  • I feel incredibly stupid that I can understand PHP and yet can't understand the simple structure of Wordpress.
    – Jesse J.
    May 26, 2015 at 20:39
  • Just omit action to POST to a current page. Your code works in principle, but a lot of unfinished stuff. WP is PHP, it's just very convoluted and old PHP at times. :)
    – Rarst
    May 26, 2015 at 20:42
  • I only have page-rebrander.php in my plugin, I haven't used options.php or admin_post.php yet, probably the very reason. The code you see above is mostly what I have. Should "if($_POST['Rebrand']) {" be moved to another file? I also haven't used add_action yet either as it talks about hooking functions but I haven't really seen any info I can use to make sense of. Should I have it just "<form>" or "<form action="admin-post.php">"? Is it right to have <input type="text" name="Website" id="Website" value="#YOURSITE.COM#">?
    – Jesse J.
    May 26, 2015 at 21:03
  • And your code mostly works. If you use just <form> then data will go to the page you have created. The rest of it is just unfinished code - you are checking for Rebrand which isn't actually in your form, you are making replacements, but not assigning results...
    – Rarst
    May 26, 2015 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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