Searching for Inactive Groups and Past Group Leaders

I’m back with this week’s tutorial, and it’ll cover a topic that was mentioned in Church Community Builder’s The Village.

The person that had a question was from another church and here’s their exact text:

We are trying to invite small group leaders who no longer serve to consider leading again.

In the past, ‘Group Leader and ‘Assistant Group Leader’ were not positions, so we cannot use the searchable “Filled in the Past’ position status.

Does anyone have another suggestion? I don’t think CCB provides a way to search historical data, though it exists on every profile.

Now there were a few responses in regards to using the advanced group search feature, selecting and exporting inactive groups.

The wrinkle to their question was actually not search inactive or old group profiles, but whether or not past group leaders could be searched for and obtained when using the advanced group search feature.

Not being able to use the advanced group search feature as previously thought, today’s tutorial focuses on how to obtain main leader information for inactive groups.

We’ll search for the data and save it to an excel file. If you’re ready, then let’s get this group party started!

Variable Setup and Configuration Includes

Believe it or not, this is really not a new tutorial. The focus of this tutorial may be new, but how we retrieve and save data is not.

There are numerous tutorials that search for group data as well as a tutorial about saving data as an Excel/CSV file.

Review and use those tutorials for greater insight about the ins and outs of group data and file save/creation.

That said, open a text editor of your choice, creating and saving a file named groups-inactive-excel.php.

Don’t forget to include the necessary comments and file inclusions.

The very next action you’ll want to take is defining the following variables:

  • apiService – Set the value to be the group_profiles CCB API service
  • fileName – the file name you would like your data saved too

As for the filename I’m saving data too. I tend to use .csv and then open the file in Excel and save it as a .xls or .xlsx file.

After variables are set and defined their respective values, then its time to set and define the urlData variable.

As for the urlData variable value, bind the following variables and labels as an array, using the array_filter method without a callback:

  • srv => apiService variable
  • include_participants => 0 (zero)

Time for API Call and Parsing of the Response Data

Okay it’s time for the heavy lifting in terms of making the API call and parsing the XML response data.

To make the curl API call to retrieve group profiles, use the ccbDetails function, passing get as the first argument and the urlData variable as the second argument.

Once the call has completed, then data is ready to be parsed. To parse the XML response, we’ll make use of XPATH query function and the following XPATH query expression: //groups/group/. They’ll be assigned as the value of the nodes variable.

As usual, we set a blank response_object variable to make sure we’re starting with a clean slate and no previous data.

Next, define the headers of the Excel / CSV file as the value of the response_object variable as shown below:

  • GroupName
  • First Name
  • Last Name
  • Full Name
  • Email

Now it’s time to iterate through each group and obtain the main leader information. To do so, use a foreach statement and iterate using the nodes variable as a node variable.

Within the foreach statement, check to ensure the group you’re returning is currently set to inactive using an if statement (see below).

Within the if statement, set the response_object variable to concatenate the following values for each main leader using the .= operator:

  • name (i.e., group name)
  • first_name
  • last_name
  • full_name
  • email

After this step, use echo to print the response_object data to the web browser viewing area to for your review.

The final step of the process is opening, writing and saving the file data, and closing the file (see below)

Time to test out your newly found inactive groups report

Today’s tutorial is just that easy! Now put it altogether, save the file, and execute it via a web browser to see what you get back.

Hopefully, a list of inactive groups with their main leader is returned.

You can now contact old leaders and hopefully get them involved once more simply copying and pasting their email addresses into an email.

In addition, instead of saving the data to an Excel/CSV file, you could also attempt to do the following:

  • Create a group using the create_group API service and use the add_individual_to_group API service to add individuals to the newly created group

-OR-

  • Add users to a specific queue

If you choose to do either of the above, then you’ll have the capability of mass mailing the group.

Personally, I would make sure to verify the data returned is valid before I attempt to conquer the options above.

Who knows, I may just put tutorials together for those actions over the next couple of weeks.

For now, you’ll have to wait until then or attempt them yourself studying the CCB API Documentation and using previous codes to cobble together your solution.

I’m out! See ya next tutorial.

 


Please comment if this tutorial has helped you.