• Resolved vanblaisa

    (@vanblaisa)


    I’ve been using GPT to help me write a plugin for a website I’m working on, I’ve had success with most of it but am now struggling when it comes to writing saving, storing and retrieving the information from the wordpress options table in the database. I’ve been going round in circles for about 2 weeks now and am way behind my deadline to get this done.

    Below is the existing code I have, any assistance to work out the problem is very much appreciated:

    [excessive poorly formatted code redacted]

    • This topic was modified 10 months, 3 weeks ago by bcworkz.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    @vanblaisa — I’m sorry but the forum’s parser made a mess of your code, making it difficult to read and impossible for others to independently test. While it’s fine to post brief snippets here if within a code block, more extensive code should be added to pastebin.com or gist.github.com. Then just provide the resulting link here.

    What sort of problem are you encountering anyway?

    Thread Starter vanblaisa

    (@vanblaisa)

    Hi bcworkz,

    Thank you for the reply. I’m having trouble saving data from an API endpoint from Hostfully.

    I can’t seem to save it to the table created within the wordpress options, nor retrieve it (should actually save).

    I’ve taken your advice and added the code to https://pastebin.com/atADsv9W

    Moderator bcworkz

    (@bcworkz)

    I don’t know the protocols for that API, but I suspect it’s not responding in a way or structure that you’re expecting. I recommend var_dumping $response, $body, and $photos (in fetch_property_photos()) to ensure everything is as expected.

    I’m not sure why ob_start() is used other than what the comment says about headers. I’m not seeing where headers are output to a client app so I’m not sure it’s necessary. Assuming it is anyway, I’d think the buffer ought to be cleared before redirecting elsewhere? As-is shouldn’t impact whatever trouble you’re having, other than you wouldn’t see the error outputs.

    Beyond that, all I can suggest is basic debugging by checking every interim variable’s content to ensure all is as expected. Obviously something’s not right along the way somewhere and it’s just a matter of finding it. You could even debug into update_option() if you had to but it shouldn’t be necessary.

    Have you confirmed if anything is saved in the options table via phpMyAdmin? There could be everything there and there’s an issue with output, not getting the API data. Presence or not outside of WP will indicate which direction you need to investigate further.

    Thread Starter vanblaisa

    (@vanblaisa)

    It turns out there was another plugin causing a conflict and it’s been resolved now, thanks for your assistance mate

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Help with correcting problems for a plugin’ is closed to new replies.