Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend Visitor Input Fields #264

Open
VR51 opened this issue Nov 15, 2016 · 6 comments
Open

Frontend Visitor Input Fields #264

VR51 opened this issue Nov 15, 2016 · 6 comments

Comments

@VR51
Copy link

VR51 commented Nov 15, 2016

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
Copy link
Owner

Hi,

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

@VR51
Copy link
Author

VR51 commented Nov 16, 2016

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

@michaeluno
Copy link
Owner

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.

  • admin-page-framework-frontend-form-beta.php - the plugin bootstrap file.
  • AdminPageFramework_FormBeta_frontend.php - an extended form class. (you don't have to pay too much attention to this one.)
  • AdminPageFramework_FrontendFormBeta_Base.php - a base class that provides methods to set up front-end forms.
  • AdminPageFramework_FrontendFormBeta.php - a class which extends the above base class and do necessary set-ups for the form.

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
Copy link
Author

VR51 commented Nov 28, 2016

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

@shahbaz-dev1
Copy link

  • Nice work, have you added Frontend_Base to the core or I'll have to use it as an add-on?
  • Where it would store the submission data?

@michaeluno
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants