Home>Support>PHP code for reading database values doesn’t work

PHP code for reading database values doesn’t work


I’m currently developing a widget for one of my clients to work with Page Builder. It contains custom PHP code to write the widget settings to and read them from a SQLite database. Everything works perfectly within the widgets page until I tested the widget in Page Builder.

I fixed all of the JS related issue in Page Builder, including PHP code to write the settings to the database. However, one issue that I cannot solve is the part where reading and displaying the saved settings from the database.

In the widgets page, everything goes in place each time I refreshed the browser. However in the Page Builder, it simply ignores reading from database and outputs the empty values that I setup.

Here are the files:

Please let me know which file and what is the problem.


This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 7 years, 9 months ago Robby Chen


    Here’s the update. It appears that the widget output in the frontend works correctly. Just the backend it doesn’t read from the database and fill out the fields.


  2. 7 years, 9 months ago Robby Chen


    I pinpointed the problem. It seems that the direct SQL statement on the Page Builder works perfectly. However, when use get_field_id() to generate an unique id, the variable refused to insert into the PDO query statement. I also tried to use the prepare statement with no luck.

    Is there any other way to get the id generated by wordpress widget class other than get_field_id method that can inserted into SQL?


  3. 7 years, 9 months ago Greg Priday Hi, I Work Here

    Hi Robby

    Glad to hear you’re developing widgets for Page Builder. Page Builder works with widgets in a slightly different way to the standard WordPress widget areas. We had to make these changes for the widgets to work with the drag and drop interface.

    One of the major changes we made was filtering the field IDs. Unfortunately the only suggestion I can make is to rework the logic of your code to not rely on this field ID as a database key.

    Sorry I couldn’t be more helpful at the moment.

  4. 7 years, 9 months ago Robby Chen

    Hi Greg,

    Thanks for the feedback.

    It seems that I have to create a settings page to configure and save the buttons. And then let the clients choose the list of buttons they already set up through the Page Builder plugin. What do you think?

    Again,, thanks for your feedback.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More