Session

Code techniques for handling dynamic data in the new(ish) world of blocks

The starting point for blocks is clear and easy: at page-build time, you can configure blocks and add content to them. This gets converted into HTML and displayed, more or less statically, in the end-user’s browser.

But what if you want your block to react to what the member level of the current user is? You can embed JavaScript in the HTML of your block, but all the familiar variables from the back end server PHP are unknown to you. Can you pass them into the block? Can you call back to the server to get the data before the block is rendered?

If you have a form in your block, can you post the data you collect back to the server? Can you use Ajax for this? What if you’d like to prefill the form with the current data, let the user edit it, and then save it back? Can you rerender the block as the user interacts with them?

The answer to all of these is yes. In the workshop, we’ll (quickly) work through live examples of all of these. If you’re OK with setting up a local installation of WP, you’re invited to follow along.

Speaker

WordCamp Europe 2023 is over. Check out the next edition!