I want to grab data from CoursePress using PHP

1. People (coaches)

WordPress username – UniqueID

Name – Firstname, Lastname

GroupID (wordpress roles)

2. People roles – Roles in wordpress

UniqueID of the role

Name of the role

3. CoursepressCourse:

CoursepressCourse UniqueID,

CoursepressCourse Name

List of registered students by ID

1. People: are registered in a GravityForm, their user was created at registration, so the unique wordpress username is also in the form.

I wish to select all the items from the form from a .php code and populate $persons = array

2. People roles I wish to query all the roles and populate $group = array

3. CoursepressCourse: I wish to select all the CoursePress Courses with the registered users and populate $exams = array

Here you can see an example of the file and also the .php file with the values

header ('Content-type: application/json; charset=utf-8');
$type=isset($_GET['type']) ? $_GET['type'] : 0;

if ($type=='groups'){
$group = array(
['id'=>1, 'name'=>'1. group']
$result = $group;
if ($type=='persons'){
$persons = array(
['id'=>wpuser1, 'name'=>'1. coach', 'mksz_code'=>'12345', 'group_id' => 1],
['id'=>wpuser2, 'name'=>'2. coach', 'mksz_code'=>'23456', 'group_id' => 1],
['id'=>wpuser3, 'name'=>'3. coach', 'mksz_code'=>'34567', 'group_id' => 1]
$result = $persons;
if ($type=='exams'){
$exams = array(
['id'=>coursepresscourseid1, 'name'=>'CoursePress Course Name 1 - coursepresscourseid1', 'persons'=>array(wpuser1,wpuser2,wpuser3)],
['id'=>coursepresscourseid2, 'name'=>'CoursePress Course Name 2 - coursepresscourseid2', 'persons'=>array(wpuser1,wpuser3)],
$result = $exams;

echo json_encode($result);