Hi there,
I would like to achieve 2 things:
1. get the IDs of all forms into an array
2. get the IDs of all active forms into an array
Could you help me achieve this? Thanks!
Hi there,
I would like to achieve 2 things:
1. get the IDs of all forms into an array
2. get the IDs of all active forms into an array
Could you help me achieve this? Thanks!
Hi, Sascha,
You can take a look at the Gravity Forms' function "get_forms" located in forms_model.php. This function gets all the forms in the database and you can pass a parameter to it (0 or 1) indicating whether you want to get the active (1) or inactive (0) forms. If you leave off the parameter, all forms will be returned. You could use it like the code below:
//get all forms
$myforms = RGFormsModel::get_forms();
foreach ($myforms as $myform) {
//loop through the forms and write out form title and status, 0 = inactive, 1 = active
echo "Title: " . $myform->title . " Active: " . $myform ->is_active . "<br>";
}
Let me know if you have any questions.
Hi Dana,
thanks for this. That will help me along!
What does this syntax (RGFormsModel::get_forms();) with the colons and the RGFormsModel actually mean/do? Why can I not just call get_forms(); ?
You won't be able to just call get_forms. The "RGFormsModel::get_forms()" tells the code to run the function get_forms() that exists within the RGFormsModel class. That class exists in forms_model.php . There could be other plugins with a function named get_forms, using this syntax you tell the code to use Gravity Forms' function.
Thanks for explaining this!