I have created a plugin that uses a shortcode [MyCreditStatus] to display a form (multi-page form). This plugin uses an API that I also made.

When I try to install the plugin, there are times that it causes a redirect loop. It also does not run properly locally because of the sessions (headers already sent, etc.) There are times that it works well too.

This is the first plugin I've made using WordPress and I'm not really familiar with WordPress plugin development and I find the resources so limited. I can't find a resource for dealing with forms and passing variable values from page to page.

Can you please see the plugin I've made and suggest ways on the correct way that I should be doing it?

Here's the download link for the plugin: http://1drv.ms/1qYoTIx

Thank you.

| improve this question | | | | |

Maikel / Michael: I will say, that's an impressive amount of work. I've not created a admin plugin with that much detail. I will admit, I'm not totally clear on every single detail of what is going on with this one, but I gather it creates a form on the one's site, then submits that to a credit reporting agency in South Africa via a curl request. Is that your API at the credit reporting company?

The one thing I did notice was the XML generation string in the files regp1.php, regp2 and regp3.php. You are generating a string, and in a couple of places instead of the value of your php variables you are only inserting the string with the variable name instead (check out the line $xml .= "<UserID>$uid</UserID>"; shouldn't that be $xml .= "<UserID>".$uid."</UserID>"; ?? ditto on the header lines after the call to sendXMLRequest?

Is the variability in results from the wordpress submission or from the API return functioning?

And what I really want to know... is that monthly free credit report only available to folks in South Africa or will that function worldwide?

Again, nice work. Zip.

| improve this answer | | | | |
  • Thanks. Yes, it creates a form when you put the [MyCreditStatus] shortcode in a page/post. It will then transmit the data to the API and process it there. Regarding the XML, it's just the same because when you put a variable inside the double quotes ("$uid"), the variable will be replaced by its value. The credit report system is only available to SA since it validates SA ID numbers only. – maikelsabido Jun 17 '14 at 6:38
  • Ouch on the " variable " quote thing. My bad. I learned something today. Many thanks. On your redirect issue, can you explain more? When you watch the output in Firebug or chrome developer tools are you seeing normal messaging and response from the curl (or is the redirect issue before the curl request is ever sent?) I have had some issues with custom plugin blocks being hooked too early or too late within the wordpress timing sequence. You're hooked to 'admin_menu'. How did you come up with that choice? – zipzit Jun 17 '14 at 6:45
  • Actually, I really have no idea as I'm new to WordPress plugin development. I did not even know that I'm hooked to admin_menu. The redirect loop thing just happens when I press the submit button in the form so I'm guessing there's a problem with the action="" in the form since that's the URL where the values are passed (regp1.php, regp2.php and regp3.php). Not sure though. :( – maikelsabido Jun 17 '14 at 6:51
  • Been checking. I think you did it exactly correct. You've got some admin setups and ID's that are done in the admin screen. Your shortcodes are registered correctly with the add_shortcode calls. I don't know why you'd be getting errors. echo <script> alert()... and var_dump() are your friends! (and yeah, I know that's bad... sometimes it works...) – zipzit Jun 17 '14 at 7:17
  • One thing I'm looking at is the response function after the curl call. You have some parameters that are attached to the end of the wordpress home url. I think you need to send those post, not get. I think wp core controller will choke on those? (? With my error above, you can gauge my total understanding of php and if($stat == "Success"){ header ("location: $siteurl?p=$pid&step=2&uid=$rid"); ) Can you take ?p=.. stuff out and test for WordPress errors? – zipzit Jun 17 '14 at 7:29

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.