0

i'm Graphic Designer and I was recently hired as a front-end at an agency. There I have a lot of demand for landing page with forms. I currently create forms with contact form 7 and the newsletter plugin. I know it's possible to create custom fields and I've made them. But I do not completely understand how to save the data from these custom fields.

Today I found a plugin that might work as I need but I'm still testing, it's called "cfdbplugin.com". If anyone can give me a light I would be very pleased. PS: For example, in CF7 we can create radios buttons but i dont know how to store this data. I can send it by e-mail but i would like to keep it in a database.

Thank you!

0

Quick Edit regarding lists:

If you are just talking about collecting emails and other info for lists, and those persons are not intended to be users of the site, I would look into posting your form to the service that will be handling the list. Any of the major services would have tutorials regarding "hosting your own sign up form".

In your form, the action attribute would be a link they provide.

<form action="http://some-link-privided-by-sevice/" method="POST">

And the name attributes of the input field(s) would correspond to some value on their end as well, since their script would be handling the data submitted.

<input type="text" name="the-name-they-want" value="" />

There will also be some hidden fields required to pass a secret key of some kind generated on their end. (An example from the service Mailchimp):

    <form action="http://mailchimp.us8.list-manage.com/subscribe/post" method="POST">

    <input type="hidden" name="u" value="a123cd45678ef90g7h1j7k9lm">

   <input type="hidden" name="id" value="ab2c468d10">
    //your input fields
   //submit button
   </form>

Getting Form Data in General

If posting the form to a function of your own, you access those input fields as parts of the $_POST array:

if (isset ($_POST['u'] ) ) { 
   //do stuff with set value 
}

Within wordpress you can utilize wp_ajax_nopriv for non-logged in users when posting a form to admin-ajax.php: action="<?php echo admin_url('admin-ajax.php'); ?>"

See the linked tutorial below about posting from the front end to adapt it to your needs if that's case.

Other Data Collection

With collecting data from forms, you are, essentially, talking about posting from the frontend of the site. Something like this tutorial on posting from the frontend should get you in the right direction. The wp-api could be leveraged for this as well (not sure if that tutorial gets into it that or not).

Some more details and things to keep in mind: I can't speak on the particular plugin you mentioned, but in terms of saving form data to the wordpress database, there are a couple things to consider. Most importantly: Validating, Sanitizing, and Escaping and the use of nonces

Saving the form entry from the frontend is creating a new post, and adding those custom fields to that post (custom fields are just post meta keys/values). So in addition to wp_insert_post, it would use update_post_meta()

To easily exclude this type of posting from other posts, I usually relegate it to a specific custom post type for organizational purposes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.