0

With this code I created contact, but only when I'm authorized.

        civicrm_api4('Contact', 'create', [
            'values' => [
                'contact_type' => 'Individual',
                'checkPermissions' => false,
                'first_name' => $_POST['first_name'],
                'last_name' => $_POST['last_name'],
                'display_name' => $_POST['username'],
            ],
        ]);

But when I'm logout:

enter image description here

1 Answer 1

1

The checkPermissions line should be outside the values array. You can use http://{your-site}/civicrm/api4 to use the explorer to construct the correct code.

        civicrm_api4('Contact', 'create', [
            'values' => [
                'contact_type' => 'Individual',
                'first_name' => $_POST['first_name'],
                'last_name' => $_POST['last_name'],
                'display_name' => $_POST['username'],
            ],
            'checkPermissions' => false,
        ]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.