最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Programmatically populate form fields with data

programmeradmin3浏览0评论

I want to create my own code for displaying and editing a logged in user's profile.

For that I want to create a form inside a Wordpress page and pre-populate the form fields with data before the page is displayed. I want to do this independently of any plugin providing form widgets. This raises the following questions for me:

  1. Is there a general form and form data handling mechanism in Wordpress that I can facilitate for this, like e.g. Wordpress has a form object containing a "field" or data object for each of the form's fields, allowing me to access the form(s) on a page?

  2. I actually wouldn't even need a form object. Instead, I could just place a couple of input fields on the page. How would I access these in some php function?

  3. How would I access the forms (is there e.g. a Wordpress function receiving the form name and returning me a form object?)

  4. How would I intercept loading of the page containing the form(s) (or any page, that is) before it gets rendered, but after the form object is instantiated/initialized?

As I said, I am not looking for a particular form implementation by e.g. some plugin, but whether there is a general underlying mechanism, which might eventually be utilized by such plugins, I could facilitate.

I want to create my own code for displaying and editing a logged in user's profile.

For that I want to create a form inside a Wordpress page and pre-populate the form fields with data before the page is displayed. I want to do this independently of any plugin providing form widgets. This raises the following questions for me:

  1. Is there a general form and form data handling mechanism in Wordpress that I can facilitate for this, like e.g. Wordpress has a form object containing a "field" or data object for each of the form's fields, allowing me to access the form(s) on a page?

  2. I actually wouldn't even need a form object. Instead, I could just place a couple of input fields on the page. How would I access these in some php function?

  3. How would I access the forms (is there e.g. a Wordpress function receiving the form name and returning me a form object?)

  4. How would I intercept loading of the page containing the form(s) (or any page, that is) before it gets rendered, but after the form object is instantiated/initialized?

As I said, I am not looking for a particular form implementation by e.g. some plugin, but whether there is a general underlying mechanism, which might eventually be utilized by such plugins, I could facilitate.

Share Improve this question edited Jun 8, 2021 at 18:00 vancoder 7,92428 silver badges35 bronze badges asked Jun 8, 2021 at 15:08 RazzupaltuffRazzupaltuff 1396 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Is there a general form and form data handling mechanism in Wordpress that I can facilitate for this, like e.g. Wordpress has a form object containing a "field" or data object for each of the form's fields, allowing me to access the form(s) on a page?

No, there is not.

I actually wouldn't even need a form object. Instead, I could just place a couple of input fields on the page. How would I access these in some php function?

The same way any other PHP/HTML application would. WordPress does not provide a form API.

How would I access the forms (is there e.g. a Wordpress function receiving the form name and returning me a form object?)

How would I intercept loading of the page containing the form(s) (or any page, that is) before it gets rendered, but after the form object is instantiated/initialized?

You don't, there are no form APIs or objects in WordPress, that is not a feature WordPress implements.

As I said, I am not looking for a particular form implementation by e.g. some plugin, but whether there is a general underlying mechanism, which might eventually be utilized by such plugins, I could facilitate.

No such mechanism exists. Each form plugin builds their form system from scratch. Some use custom tables to store the data, some use custom post types, but there is no generic system that sits underneath them. You would have to build it yourself or use a 3rd party plugin/library to provide it.

发布评论

评论列表(0)

  1. 暂无评论