WordPress Plugin Integration
What is this? A production-ready WordPress plugin that rewards your site visitors with LTZ tokens for engaging with your content (comments, signups, daily visits, etc.).
Use this if you're: Running a WordPress site and want to reward user engagement and loyalty.
You'll need:
- A WordPress site (self-hosted or WordPress.com Business plan)
- A Loyalteez Partner Account
- 10 minutes
🚀 Quick Start (Recommended)
We've built a production-ready WordPress plugin that handles:
- ✅ Dynamic Event System (add unlimited events)
- ✅ Automatic Rewards for Comments, Signups, Daily Visits
- ✅ Flexible WordPress Hook Integration
- ✅ Server-Side API Calls (no CORS issues)
- ✅ Easy Admin Configuration
📦 View the Repository
Clone the repository and install the plugin:
git clone https://github.com/Alpha4-Labs/wordpress-demo.git
cd wordpress-demo/wordpress-loyalty-plugin
Or download the plugin zip directly.
🎮 Try Live Demo
Test the plugin instantly in your browser using WordPress Playground - no installation required!
How It Works
Plain English Explanation:
- User does something (leaves a comment, signs up, visits daily, etc.)
- WordPress triggers a hook (e.g.,
comment_post,user_register) - Plugin sends event to Loyalteez via server-side API call
- User gets LTZ tokens automatically
Step-by-Step Setup
Step 1: Install the Plugin
Option A: Upload Plugin (Recommended)
- Download the plugin: wordpress-plugin.zip
- Go to WordPress Admin → Plugins → Add New → Upload Plugin
- Upload the zip file and click "Install Now"
- Click "Activate Plugin"
Option B: Manual Installation
- Clone the repository:
git clone https://github.com/Alpha4-Labs/wordpress-demo.git - Copy the
wordpress-loyalty-pluginfolder to yourwp-content/plugins/directory - Go to WordPress Admin → Plugins
- Find "Loyalteez Rewards" and click "Activate"
Step 2: Configure the Plugin
- Go to: WordPress Admin → Settings → Loyalteez Rewards
- Enter your Brand ID:
- Log in to Partner Portal
- Copy your Brand Wallet Address from the dashboard
- Paste it into the "Brand ID" field
- Configure Domain Authentication:
- In Partner Portal → Settings → Profile → Authentication Methods
- Under "Domain", enter your website URL (e.g.,
https://yourbrand.com) - This authenticates events from your domain
Step 3: Add Events
The plugin uses a dynamic event system - add as many events as you need:
- Click "Add Event" in the settings page
- WordPress Hook: Enter the hook name (e.g.,
comment_post,user_register) - Loyalteez Event Name: Enter the exact event name from your Partner Portal
- Enable: Check the box to activate
- Save Changes
Common WordPress Hooks:
comment_post- When a comment is posteduser_register- When a new user registersinit- On every page load (for daily visit tracking)wp_login- When a user logs inpublish_post- When a post is publishedwoocommerce_order_status_completed- WooCommerce order completion
Important: Event names must match exactly what you've configured in Partner Portal → Settings → LTZ Distribution.
Step 4: Test Your Integration
-
Use the Test Button:
- Scroll to "Test API Connection" section
- Enter a test email and event name
- Click "Send Test Event"
- Verify success or check error messages
-
Test Real Events:
- Leave a comment on a post (if
comment_postis configured) - Register a new user (if
user_registeris configured) - Check your Partner Portal → Analytics to see events
- Leave a comment on a post (if
Code Example
Here's how the plugin sends events to Loyalteez:
/**
* Send event to Loyalteez API
*/
public function send_event($event_type, $email, $metadata = []) {
$body = [
'brandId' => $this->brand_id,
'eventType' => $event_type,
'userEmail' => $email,
'domain' => parse_url(get_site_url(), PHP_URL_HOST),
'metadata' => array_merge([
'platform' => 'wordpress',
'timestamp' => current_time('c'),
], $metadata)
];
$response = wp_remote_post('https://api.loyalteez.app/loyalteez-api/manual-event', [
'body' => json_encode($body),
'headers' => [
'Content-Type' => 'application/json',
'User-Agent' => 'Loyalteez-WordPress-Plugin/1.0.0'
],
'timeout' => 15
]);
return wp_remote_retrieve_response_code($response) === 200;
}
Programmatic Event Sending
You can send events from your theme or other plugins:
// Load the API class
require_once WP_PLUGIN_DIR . '/loyalteez-rewards/includes/class-api.php';
// Send a custom event
$api = new Loyalteez_API();
$api->send_event('custom_event_name', '[email protected]', [
'custom_data' => 'value',
'source' => 'my_custom_function'
]);
Reward Strategies
Strategy 1: Comment Rewards
Why: Encourages engagement and discussion.
How: Configure comment_post hook → post_comment event.
Strategy 2: Daily Visit Rewards
Why: Encourages repeat visits and daily engagement.
How: Configure init hook → daily_visit event (plugin handles 24-hour cooldown).
Strategy 3: Signup Rewards
Why: Rewards new user registration, encourages account creation.
How: Configure user_register hook → user_registration event.
Strategy 4: Content Sharing
Why: Encourages social sharing and viral growth.
How: Add share buttons with loyalteez-share class (plugin handles AJAX).
Frontend Integration
Add Share Buttons
The plugin includes frontend JavaScript for share rewards:
<button class="loyalteez-share" data-url="https://yourbrand.com/awesome-post">
Share for Rewards
</button>
The plugin automatically:
- Prompts for email if user isn't logged in
- Sends AJAX request to WordPress backend
- WordPress backend calls Loyalteez API
- Shows success/error message
Custom Frontend Events
You can trigger events from JavaScript:
// Via WordPress AJAX (requires nonce)
jQuery.post(ajaxurl, {
action: 'loyalteez_custom_event',
nonce: loyalteez_vars.nonce,
event_name: 'custom_action',
email: '[email protected]',
metadata: { custom: 'data' }
});
Troubleshooting
"Events aren't triggering"
Check:
- Are events enabled in plugin settings?
- Do event names match Partner Portal exactly?
- Enable Debug Mode and check
wp-content/debug.log - Use "Test API Connection" button
"API returns 403 Forbidden"
Check:
- Is your domain configured in Partner Portal → Settings → Profile → Domain?
- Domain must match exactly (including
https://orwww) - Example: If your site is
https://yourbrand.com, enter exactly that
"API returns 400 Bad Request"
Check:
- Does the event name exist in Partner Portal → Settings → LTZ Distribution?
- Event names are case-sensitive
- Use "Test API Connection" to see exact error message
"No CORS errors but events don't work"
Note: The plugin makes server-side API calls (no browser CORS). If you see CORS errors, they're from:
- WordPress Playground loading the plugin zip (use proxy URL)
- Frontend JavaScript (check browser console)
Debug Mode
Enable Debug Mode in plugin settings to log all API requests/responses:
- Go to Settings → Loyalteez Rewards
- Check "Enable Debug Logging"
- Ensure
WP_DEBUGis enabled inwp-config.php:define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true); - Check
wp-content/debug.logfor[Loyalteez]entries
Architecture Notes
Server-Side Processing
- All API calls are made server-side via PHP
wp_remote_post() - No browser CORS issues
- Secure (API keys never exposed to frontend)
Dynamic Hook System
- Plugin dynamically registers WordPress hooks based on configuration
- Supports any WordPress action hook
- Automatically extracts user email from hook context when possible
Domain Authentication
- Each event includes your site's domain
- Partner Portal validates domain matches configured website URL
- Prevents unauthorized use of your Brand ID
Support
- Official Repository: github.com/Alpha4-Labs/wordpress-demo
- Live Demo: WordPress Playground
- WordPress Hooks: WordPress Developer Reference
- Loyalteez API: Event Handler API
- Need help? [email protected]