PHP code example of phil / guardian-consent

1. Go to this page and download the library: Download phil/guardian-consent library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phil / guardian-consent example snippets


use Phil\GuardianConsent\CalendarDate;
use Phil\GuardianConsent\Feature;
use Phil\GuardianConsent\Guardian;
use Phil\GuardianConsent\GuardianId;
use Phil\GuardianConsent\MemberId;
use Phil\GuardianConsent\NoticeVersion;

$member = new MemberId($user->id);

$consent->register($member, CalendarDate::fromString('2013-05-02'));  // the date of birth is read, not kept

$consent->allows($member, new Feature('messages'));                    // false: refused until a guardian grants it

$consent->request(
    $member,
    new Guardian(new GuardianId($parentAccountId), '[email protected]'),
    [new Feature('messages'), new Feature('public-profile')],
    new NoticeVersion('2026-11'),
);                                                                      // the notifier sends the link

// On the page the link opens, then on its form:
$request = $consent->open($token);
$consent->decide($token, [new Feature('messages')]);                    // messages granted, public profile refused