 Welcome back to the channel. In today's video, I'm going to show you how to use gravity forms and tap the information that's coming in through the form submission and then send it to an API or send it to somewhere different. Now, if you haven't seen my video where I show you how to do the exact same thing with contact form 7, you can see the card that has just popped up right now or you can check in the description to see that particular video. Otherwise, let's jump into creating a form and if you don't want to see the whole process of creating a form, you just want to be able to tap your information and send it. Then you can check the video chapters down in the description and skip to the part where we start tapping that information and sending it. Otherwise, let's jump into creating a form for those who have never used gravity forms and see the power that gravity form actually has. Now, I've installed version 2.4 so I'm going to activate my gravity forms as a plugin and then I'm going to get a new part here that says forms so I'll click new form. I'm going to call this inquiries and I'll say inquiries from my suppliers. So I'll create the form and this will give us this field that looks like this but the new version of gravity forms will actually take you to something that looks like a post. So in here I'm going to do very simple things. I'm going to add a single line and basically this is going to be the name. Now with gravity forms of course they will allow you to add so you can say this is the business name and you will see that as you add those different features they actually show up right here. Let's move to the appearance panel so we can add name here and it will show up like what we see here. We can have our field increase in size by saying large so it will complete the full width or medium to take up just a small portion and if it's small it will be really really small. So I'll go for medium as a size. You can add custom classes if you need to and then style it and then you can have a custom validation message and say maybe please enter a name because someone might have missed adding that field. You can choose to say I don't want to see that label up there and you can choose it to be hidden or you can leave it as shown and then you can choose to say let the description be above the input so you'll have this description showing right up here. So there are a couple of things that you can do to make your form look much better and in the advanced section there are a couple of things that you can do. You can have a default value for example. You can change how this is viewed in that mean so I'll add this as a medium so that when we see that when the form has been submitted you'll be able to see this. We can always add a default value if someone misses but in this case we don't want anyone to skip this so we have all these fields right here but I'm going to go into the advanced fields and I'm going to choose an email address because I want to be able to reply to the email and what I'm going to do is add a confirmation for the email. I want someone to be able to confirm their email so that in case they have messed it up they will automatically get something telling them hey you messed up on your email and then I'll put a field as required to show that our email is required and then in the appearance we leave the fields as media so we'll save our form and then after that I am going to add a couple of other things for example I need to be able to check their order and I will say how many pieces of items do you want to order how many cars do you want to ship and then that will be the number of cars. I can choose a format and then I can choose to say we can have a minimum of one and a maximum of five and we'll say this is required and then when we go to the appearance we can set up whatever we need down here and in the advanced section we have all these fields now with this field we have a number and I'm going to move it up and the reason I'm going to do that is I'm going to ask my suppliers when they enter a number here then I should be able to get an email field in here so I'm going to come back here go to advance and I'm going to choose to add a Nebo conditional logic now what this is going to do is that it's going to show that email if all the rules that we have down here are met or if any are met so you can choose your option down here and I'm going to say let's look for the number of cars and we're going to say is number one is greater than one and then we can add another rule and say number of cars is actually less than six because we say the maximum is five so I'm going to have those as my rules and then I'm going to update this so let's go and preview our form and see so this has a name requirement so I'll put my name as techie press and then in the fields here I'm going to put three and you'll see that my email automatically shows up here now I didn't have to add this to show up after the three or so but I wanted you to see how the conditional logic actually works so if I put a number like seven it will not show but on hitting submit this is going to say the number can only be up to five so the form automatically does that validation for me but I wanted to have when someone enters something like three that automatically get the email then can feed it in so you can see the bits of differences that we have with the phone so let's close this out so with this we're now ready to have our form we'll put it on our website and then we'll have it sending information to our API or a database away from our website so the one thing that I need to do is I need to come to the settings here the settings form I can see if there is anything that I need to change here maybe enable animations if I need to and then I can limit the number of entries or I can schedule the form and say this form should only be available at particular times of the day and I might require the user to be logged in but I won't do that for now I will not also do the scheduling of the form and since my settings are all done I can actually update my form and after saving my form I can go to the confirmations and we can edit the default confirmation which is say thank you and all of that I will leave that as that and it can either be a text it can be sending someone to a particular page maybe you have a sample page or you can send them to a survey page or you can actually redirect them to a URL that you feel like this needs to be the one so in the notifications you can have an admin notification whereby the administrator will receive a message saying email ABCD was sent to you so check to see what it's saying now in particular countries you have laws about personal data so you can stop picking up of the IP address you can trash the entries that are made you can delete them automatically you can also enable integration with WordPress tools so that you can export or erase personal data depending on particular things like emails and so on so you can do export these or erase them in this section where you have tools and then export so for now I will not allow that but I will prevent the tracking of IP addresses and I will hit save so after doing that this is the admin section where you're seeing the admin name here you see that how many cards and you see that email so those are the fields that we worked with in the original instance we know that this form is actually with the ID of two but that's not something that I need to keep in memory I'm going to go to my pages and I'm going to have a new page and this page is where we're going to have our suppliers I'll call it suppliers and in here we can click on this button and you see we have this gravity form showing up right here so I'll click on select form and I'll choose inquiries and we know that it allows us to have a title a description so I'll turn those off for now and hit publish so after publishing this I can actually go and view the page and when the form opens up you'll see that we have this form right here I'll add my techie press and say I want to ship in three new cards and then my email will be techiepress at techie.com and then I'll have to confirm this particular email also here so I'll hit submit and we'll get our response right there so if I go into forms and then I just go to entries you'll be able to see that we have this showing up here now we want to be able to get this information that will be coming in and sending it to a particular API and I'm going to use an automation tool that is called Integromat that you can actually pay to use or it's actually free so I'm going to go back to our WordPress in here I'll develop a new plugin trap gravity and then I'll create in here a new file which I'll just call also trap gravity .php I'll hit enter and then we can start writing our php here so in here I'll use my snippet to start my plugin which is that plugin and then I can say trap gravity forms and then I'll change the author link techiepress I'll say this one collect gravity forms to webhook and then in here I'll have a gpl license gpl2 and then I'll just call this trap gravity I'll save this and then I'll come back to my WordPress in the admin section I'll go to plugins I'll activate this so the first thing that I'll do in my code is to add some security stuff and say let's look for whether the abs path has actually been used and we're basically saying if someone tries to use this particular php file without using WordPress the normal way then nothing should happen so I'll say if it's dying I'll say no entry so in here we're going to use a hook that comes from gravity forms and the hook that we're going to use is actually called the gform after submission when you come down the documentation you'll see that actually you have how these hooks can be used now if you want to trap all the particular forms you have on your site and you want to do something with them you can use this gform after submission but in the event that you want to use a particular form you need to know its id and in our case we know we want to deal with form id too so we're going to change this part into a tool so for now I'm going to copy this right here and not use all my forms in my site and then I'll come back here and I'll paste it and we're going to use the form 2 right here now I'll add take a press right at the beginning underscore to make sure that my function that I have here or my callback is actually going to be unique then I'll come down here and I'll say function with a function name here we'll add our brackets and then inside here is where we're going to add our running code so for now this 10 stands for priority and we are saying when the form is submitted at the priority of 10 let us run this function and this function is actually going to get two arguments passed to which right in here now those two arguments if we go back to the documentation actually entry and we also have the form so I'm going to come back to my code and I'm going to add the entry and then I'm also going to get the form now in here I'm just going to error log this and inside my error I'm going to add a print r and this is something that I use all the time to help me see the data that I'm actually getting before I manipulate it or do with it with anything and since print r expects this to be a string we're going to come here and add a comma and then we type in a boolean of true now this error log function will only work if in your wp config you've actually added this rule and what it's going to do is that it's going to add a new file inside your wp content right here and you'll see debug.log or you can actually shift it to another place if you don't want it to be in your wp content folder so I really don't have a preference over that so I'm going to just serve this with my wp debug log as true I'm going to come back to my front end I'll click my suppliers page hit enter here to reload it and I'm going to add a new name and say I am John Doe I'll be shipping two cars and then I'll be John one at John.com and then I'll need to do the same thing at John.com right here and then I'll hit submit of course I'll get my message thanking me and when I come back to entries here and reload you'll see we have John Doe with two and then the email is this but when I come back to my editor I'm going to go right here and I'll reload my files and you'll see that we have a new debug.log right here and when I click on it you'll see we have our ID of seven that is generated by the form we have all this information but we have an entry of one two and three and these are the names that we need so I'm going to copy this and I'm going to come back to our editor right here inside our development and I'll paste this here so that I can quickly reference what we need and then I can also just use the form ID to make sure that I'm working with the exact form that I want so I'll copy this and then put it here we'll use the form ID and then we'll validate the information that we have here so I'm going to just comment this out as well and this is what I'm going to say the first thing that I'll do is say if we're actually using the right form so we'll say if our entry and then we shall say let's use the information we have here if our entry is actually getting a form ID that is equal to two and I need to have two equal signs right here to say that is two I'm not assigning this to be equal to two I'm verifying is it true that it is equal to two yes if it is equal to two then we shall do the following information in here meaning we're getting the right form and it's going to send the right data so if we are on the right form right here so we're going to say this is our info it's actually going to equal to an array so I'll use the square brackets for now and I'll say let's get this information right here I'll say the name that we have we're going to map it to our entry and we are looking for item one I'll put a comma at the end I'll duplicate this thrice so that we can be able to say number three is going to be our number of shipping items and then this will be our email and I would say this is going to be two so I'll just push this over so that they look a little bit neater and I can actually take this away because I'm done using it for now and after getting our info right here the next thing that we're going to do is we're going to use the wp remote post which takes in a url and it takes in a couple of arguments like our headers our body so whenever you're doing an http post or you're sending information to another api you need to have all this information in so I will set my url right here and say it's going to equal to these quotations and I'll come back to my browser and I'm going to open up an automation tool inside integromat.com that will allow us to pick information and we can do whatever we want with it so for now I'm going to go to create a new scenario and I'm going to be getting a webhook because that's what I want to have I'll click continue and then I'll choose a webhook right here and I'll say this is going to be a custom webhook that's receiving information and we're going to add a webhook name to it and I'll say gravity entries and I'll not restrict the ip that it's coming from and I'll hit save and you'll see that we now get a new url showing up here which I'll copy and then we're going to click this little button which says it wants to determine what kind of data is actually going to come in into our integromat so I'll go back to my code here and I'll paste this link right here in our url and we know that we are going to be sending information so we also need to add a method here and we'll say this method is actually going to be a post method because WordPress sends all remote posts with a method of get so we need to be explicit here by saying we're going to be posting data so I'll save this here we'll go back to our browser this is still waiting so I'm going to go to the suppliers here and I'll say let's send John Doe and then we'll say John Doe is sending focus we'll say John at one.com I'll add the other email and then I'll hit submit and you'll see that here once the webhook receives the data it says it's successfully determined and now we can click okay right here now I'll add an extra module here that's going to convert our data that is received and just aggregate it as a JSON so a module of JSON and this will aggregate to JSON so I'll add it here and so it's going to pick its data from this webhook so it automatically detects the webhook that is here and adds it as a source module because of this little link that we've added now we need to add a data structure and I'll say let's call this our JSON data array and then I'll click add an item because we'll expect a name which will be text and we'll say that's required we'll add also another one which will be the number and that's going to be a number type and that's also required and then I'll add the final one which is the email now say that's a text it's required and add it as well so I'll hit save here and you'll see that this automatically loads up for us these fields so that we can populate them with the information that's coming from this webhook so I can safely add all of this without doing any kind of coding or whatsoever so at this end after aggregating this to JSON you can actually add other modules like HTTP and so on or send this information to your email or to your google sheets and all those modules are available for you or you can even send them to your marketing tool or CRM whatever it is so for now we are set we are ready to receive data coming in from our particular suppliers so I'll hit suppliers here and I need to hit this to run so we shall come back to our suppliers here I'll hit enter on this and then we shall send in Ethan Ethan is going to send focus and then this will be his email and then I'll hit submit here and when we look here you will see that we have a new item that has been added and that's the information coming in from our spring from our suppliers form here so that's how you actually work with gravity forms with this little hook to capture all the form data add the id to the form right here and send your data to wherever you want to send that particular data remember if you want to purchase gravity forms or intergrammat you can pick from the links that I've shared inside the description and that will allow me to get a little bit of a tip from you on your purchase you won't be paying any extra from the usual but the particular businesses will allow me to get a little tip from that so if you enjoyed this video don't forget to give it a thumbs up leave me a comment letting me know how you found it how you're going to apply it or if you have any challenges and you can share this with all your friends who are learning about sending data from gravity forms or if they need to use a form and send it to their particular API otherwise enjoy whatever you're coding and goodbye