Contents
On this page

Submit Testimonial - Plugixa Testimonial

POST /plugixatestimonial/v1/frontend/submit

Store a testimonial sent by a visitor, as the submission form does.

Public: no authentication. It needs Enable form on in the submission settings (on by default).

Note. A submission is saved with the Default status setting (pending unless changed), or approved straight away when Auto-approve is on. source is frontend_form. Nothing limits how often one visitor can submit: turn on reCAPTCHA for a public form. See Submission form.

Request links are not checked here. A pxt_request_token marks its request submitted even when the link has expired. Check it first with Check Request Token.

Request

POST https://your-site.example/wp-json/plugixatestimonial/v1/frontend/submit

Request body

Content type: application/json, or multipart/form-data to include a photo

Field Type Required Description
client_name string See below Plain text.
testimonial_text string See below Plain text: tags are removed. Between the Minimum and Maximum length settings (10 and 2000 by default), counted in bytes.
rating integer No 1 to 5, clamped. Defaults to 5.
client_role string See below Plain text.
client_company string See below Plain text.
website_url string See below Must be a valid URL when sent.
email string See below Must be valid when sent. Stored privately with the testimonial, never shown on the site.
custom_fields object See below Values keyed by field key. Only published fields shown on the front end are kept; number, url, date and color fields are type-checked.
client_photo file No Multipart only, and only when Photo upload is on. JPEG, PNG, GIF or WebP, 2 MB at most.
recaptcha_token string See below Required when reCAPTCHA is on: a v3 token from the site key.
language_code string No The testimonial’s language. Defaults to the current language when WPML or Polylang is active.
pxt_request_token string No The token of a testimonial request link, to mark the request submitted.

Which fields are required comes from the Required fields setting, by default client_name, testimonial_text and rating. A custom field marked required must be filled. When admin notifications are on, the recipients get a “new testimonial” e-mail.

{
  "client_name": "Lucas Bernard",
  "client_company": "Atelier Nord",
  "email": "lucas@example.com",
  "testimonial_text": "Clear, fast and friendly support from day one.",
  "rating": 5,
  "custom_fields": {
    "project_type": "Branding"
  }
}

Responses

200 OK. data.id is the stored testimonial.

{
  "success": true,
  "message": "Thank you for your testimonial! It will be reviewed shortly.",
  "data": {
    "id": 57
  }
}
Field Type Meaning
data.id integer The new testimonial’s id
message string The Success message setting

Errors

Status Code When
403 rest_error “Testimonial submissions are currently disabled.”
400 rest_error “reCAPTCHA verification required.” or “reCAPTCHA verification failed.”
403 rest_error “reCAPTCHA score too low. Please try again.”
400 rest_error “Invalid file upload.”, “File too large. Maximum size is 2MB.” or “Invalid file type. …”
400 rest_error “Validation failed”. data.errors names the field: a required field, email, website_url, the text length or a custom field.
500 rest_error “Failed to upload photo.” or “Failed to submit testimonial”

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixatestimonial/v1/frontend/submit" \
  -H "Content-Type: application/json" \
  -d '{"client_name":"Lucas Bernard","client_company":"Atelier Nord","email":"lucas@example.com","testimonial_text":"Clear, fast and friendly support from day one.","rating":5,"custom_fields":{"project_type":"Branding"}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/frontend/submit');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'client_name'      => 'Lucas Bernard',
        'client_company'   => 'Atelier Nord',
        'email'            => 'lucas@example.com',
        'testimonial_text' => 'Clear, fast and friendly support from day one.',
        'rating'           => 5,
        'custom_fields'    => [
            'project_type' => 'Branding',
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/frontend/submit', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ client_name: 'Lucas Bernard', client_company: 'Atelier Nord', email: 'lucas@example.com', testimonial_text: 'Clear, fast and friendly support from day one.', rating: 5, custom_fields: { project_type: 'Branding' } }),
});
const { data } = await response.json();

Quick Links

Share