michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Frontend Visitor Input Fields #264

Open VR51 opened 7 years ago

VR51 commented 7 years ago

Can this be used to add frontend forms that are safe for anonymous user input?

I'm in the middle of converting my own plugins to use Admin Page Framework. Would keep the code lighter if I can use the fields on the frontend too.

michaeluno commented 7 years ago

Hi,

It's not supported at the moment, sorry. However, it sounds like a good idea.

VR51 commented 7 years ago

Thank you, Michael. Would love to see it added.

michaeluno commented 7 years ago

I've dome some experimentation with front-end forms, using the APF form class. It came out to be functional. One thing to keep in mind is that you have to style the form by yourself.

If you like, you should try this demonstration plugin. Please make sure you have Admin Page Framework v3.8.11 or above.

apf-frontend

The demo plugin consists of four files.

For the usage, please see the doc-block section of the AdminPageFramework_FrontendFormBeta_Base class. Basically, you set up a custom hook and define fields and a stylesheet in an extended class. And then just instantiate the extended class. The demo plugin uses the the_content filter hook as an example. You can set your custom filter/action in your desired location. It should be strait forward. Modify the AdminPageFramework_FrontendFormBeta class and play around with it. It might be easier than writing one from scratch.

Hope you like it. Let me know if you encounter problems.

VR51 commented 7 years ago

Wow! Thank you very much. Will download and play with this in a few minutes.

shahbaz-dev1 commented 7 years ago
michaeluno commented 7 years ago

@wowthemes It's not part of the core. You have to implement it by yourself. It's just a matter of copy & paste and renaming classes though.

The submission data is not stored anywhere by itself. You want to do it by yourself in the validate() method. Just do something like update_option( $first_parameter, 'your_option_key' ) where $first_parameter is the first parameter variable of the validate() method.