WP Manifestindependent plugin directory
manifest / users / wp-credits-system

WP Credits System

A flexible credit/token wallet system for WordPress

by Shane Barron · github.com/mrshanebarron/wp-credits-system · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/mrshanebarron/wp-credits-system/archive/refs/heads/main.zip

A flexible credit/token wallet system for WordPress. Enables virtual currency functionality for any WordPress site.

Features

  • User wallet management with credit balances
  • Add, deduct, and refund credits
  • Complete transaction history
  • Admin dashboard for managing credits
  • AJAX endpoints for frontend integration
  • Extensible via WordPress hooks

Installation

  1. Upload the wp-credits-system folder to /wp-content/plugins/
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Configure via Settings > Credits

Usage

PHP Functions

// Get user's balance
$balance = wp_credits_get_balance($user_id);

// Add credits
wp_credits_add($user_id, 100, 'Welcome bonus', [
    'type' => 'bonus',
    'reference_type' => 'signup',
]);

// Deduct credits
$result = wp_credits_deduct($user_id, 50, 'Service payment', [
    'reference_type' => 'booking',
    'reference_id' => 123,
]);

// Refund credits
wp_credits_refund($user_id, 50, 'Cancellation refund', [
    'reference_type' => 'booking',
    'reference_id' => 123,
]);

// Get transaction history
$transactions = wp_credits_transactions($user_id, [
    'limit' => 20,
    'type' => 'debit', // optional filter
]);

Hooks

// After credits are added
add_action('wp_credits_added', function($user_id, $amount, $new_balance, $transaction_id) {
    // Send notification, etc.
}, 10, 4);

// After credits are deducted
add_action('wp_credits_deducted', function($user_id, $amount, $new_balance, $transaction_id) {
    // Log activity, etc.
}, 10, 4);

AJAX Endpoints

  • wp_ajax_wp_credits_get_balance - Get current user's balance
  • wp_ajax_wp_credits_add - Add credits (admin only)

Database Tables

The plugin creates two tables:

  • {prefix}_wp_credits_wallets - User balances
  • {prefix}_wp_credits_transactions - Transaction history

License

GPL v2 or later