Overview
The certificate system in Dashboard Dilemas allows you to generate and distribute digital certificates for users who complete games. Two types of certificates are available:- Participation Certificate: Awarded for completing a game
- Excellence Certificate: Awarded for achieving outstanding scores
generate_certificate
Generates a certificate PDF for a user’s game completion.This is actually a PHP page rather than a function. The page is accessed via URL with query parameters and generates a viewable/downloadable certificate.
Access URL
Parameters
User ID who completed the game. Can be numeric ID or email for guest users.
Game (dilemma) ID for which the certificate is being generated.
Certificate type: ‘participation’ or ‘award’
Certificate Types
- Participation
- Excellence
Awarded when a user completes any game session.Visual Style:
- Blue accent color scheme
- Standard certificate border
- Completion acknowledgment text
Certificate Contents
Each certificate includes:- Dilemas Éticos logo
- Client logo (if available)
- Certificate type title
- Recipient name
- Game/dilemma name
- Score badge (for excellence certificates)
- Session date
- Signature line (“Comité Evaluador”)
- Audit code (format: DE--)
- QR code placeholder
Example Usage
Page Actions
The certificate page provides two main actions:Certificate Email Distribution
api_send_certificate.php
Sends a certificate to a user via email using WordPress’swp_mail() function.
Endpoint
Parameters
User ID or email address
Game ID
Certificate type: ‘participation’ or ‘award’
Response
Whether the email was sent successfully
Error message (only present when success is false)
Example Request
Email Template
The email includes:Email structure
Email structure
Subject Line:
- Participation: ”📜 Tu Certificado de Participación - {Game Name}”
- Excellence: ”🏆 ¡Felicidades! Tu Certificado de Excelencia - {Game Name}”
- Professional HTML template with gradient header
- Personalized greeting
- Congratulatory message
- Download button linking to certificate page
- Footer with disclaimer
- Responsive design (max-width: 600px)
- Blue gradient header for brand identity
- Rounded corners and shadows
- Mobile-friendly button styling
Funnel Event Tracking
Both certificate generation and email sending register events in the funnel analytics:
cert_sent: Registered when email is sentcert_downloaded: Registered when PDF is generated
Implementation Example
Complete workflow for awarding certificates:Best Practices
Score Thresholds
Set clear criteria for excellence certificates. The default threshold is typically 80% or higher.
Email Validation
Always validate user email addresses exist before attempting to send certificates.
Error Handling
Implement proper error logging and user feedback for failed certificate generation or email delivery.
Rate Limiting
Consider implementing rate limiting to prevent abuse of certificate generation endpoints.
Related Functions
Sessions
Retrieve session data needed for certificates
Users
Get user information for certificates