Custom WordPress Plugin Development

Job ID: 38609418

Budget: $30 – $250 USD

I'm seeking a WordPress expert to create a custom plugin with multiple functions.

Key Features:
Referral System: Allows users to refer others using unique referral links. When a new user registers through a referral link, the system records the referral relationship.

VIP Level Management: Assigns VIP levels to users, which can be adjusted by the administrator. VIP levels might correspond to different privileges or benefits within the platform.

Wallet Management: Provides each user with a wallet balance that can be managed by the administrator. Admins can deposit or withdraw funds from user wallets.

Commission Calculation: Automatically calculates and updates commissions for referrers when their referred users make deposits exceeding a specified amount (e.g., $250).

Admin Dashboard Pages: Adds custom pages to the WordPress admin dashboard for managing referrals, wallets, and VIP levels.

Shortcodes: Offers shortcodes to display wallet balances, VIP levels, and amounts on the front-end, allowing users to view their information.

Performance Enhancement:
- The plugin should be designed to enhance the overall site performance, particularly improving load times and database efficiency.

Detailed Explanation:
1. Plugin Activation and Database Setup
Function: custom_referral_vip_install()

Purpose: When the plugin is activated, this function creates necessary database tables and adds new columns to the WordPress users table.

Database Tables Created:

custom_referrals: Stores referral data, including referrer ID, referred ID, commission amount, and referral date.
custom_investments: Intended for storing investment data (not fully implemented in the provided code).
User Table Modifications:

Adds wallet_balance (float) and vip_level (integer) columns to the wp_users table to store user wallet balances and VIP levels.
Before adding these columns, it checks if they already exist to prevent duplication errors.
2. Referral System Implementation
Function: set_referral_cookie()

Purpose: When a user visits the site with a referral link (e.g., yoursite.com/?ref=123), this function sets a cookie named referrer_id containing the referrer's user ID. The cookie lasts for 30 days.
Function: register_custom_referral($user_id)

Purpose: Triggered when a new user registers.
Process:
Checks if the referrer_id cookie is set.
If it is, it inserts a new record into the custom_referrals table linking the new user with the referrer.
Clears the referrer_id cookie after recording the referral.
3. Admin Dashboard Integration
Function: custom_admin_menu()

Purpose: Adds three new pages to the WordPress admin dashboard under the main menu:
Manage Referrals: View and manage referral data.
Manage Wallet: View user wallet balances and perform deposits or withdrawals.
Manage VIP: View and update user VIP levels.
4. Referral Management in Admin Dashboard
Function: display_referrals_page()

Purpose: Displays all recorded referrals in a table format.
Information Shown:
Referrer's username.
Referred user's username.
Commission amount.
Referral date.
5. Wallet Management
Function: display_wallet_page()

Purpose: Allows administrators to manage user wallet balances.
Features:
Displays a list of users with their current wallet balances.
Provides forms to deposit or withdraw amounts from each user's wallet.
Processes deposit and withdrawal transactions.
Transaction Processing:

When an admin submits a deposit or withdrawal:
Updates the user's wallet_balance in the database.
If a deposit is made, it calls update_referrer_commission() to handle commission updates.
6. VIP Level Management
Function: display_vip_page()

Purpose: Enables administrators to view and update users' VIP levels.
Features:
Displays a list of users with their current VIP levels.
Provides forms to change a user's VIP level.
Updates the vip_level in the database upon submission.
7. Commission Calculation
Function: update_referrer_commission($user_id, $deposit_amount)

Purpose: Calculates and updates the commission for the referrer when a referred user makes a qualifying deposit.
Process:
Checks if the user who made the deposit was referred by someone.
If the deposit amount is greater than or equal to $250:
Calculates the commission (e.g., 10% of the deposit amount).
Updates the commission field in the custom_referrals table.
Increases the referrer's wallet_balance by the commission amount.
8. Shortcodes for Front-End Display
Function: display_wallet_balance_shortcode()

Shortcode: [wallet_balance]
Purpose: Displays the logged-in user's wallet balance on the front-end.
Function: display_vip_level_shortcode()

Shortcode: [vip_level]
Purpose: Displays the logged-in user's VIP level.
Function: display_amount_shortcode()

Shortcode: [user_amount]
Purpose: Also displays the logged-in user's wallet balance (similar to [wallet_balance]).
How the Plugin Works Step-by-Step:
Referral Tracking:

A user shares their referral link (e.g., yoursite.com/?ref=123).
A new visitor clicks the link, and a cookie referrer_id is set with the referrer's user ID.
When the visitor registers, the system checks for the referrer_id cookie.
If present, it records the referral in the custom_referrals table and clears the cookie.
User Deposits and Commission Calculation:

An admin deposits funds into a user's wallet via the admin dashboard.
If the deposit amount is $250 or more and the user was referred by someone:
The system calculates a commission (e.g., 10% of the deposit amount).
Updates the commission amount in the custom_referrals table.
Adds the commission to the referrer's wallet balance.
VIP Level Management:

Admins can view and update users' VIP levels through the admin dashboard.
Changes to VIP levels are saved in the vip_level column of the users table.
Wallet Management:

Admins can deposit to or withdraw from user wallets.
All wallet balances are stored in the wallet_balance column of the users table.
Users can view their wallet balances on the front-end using the [wallet_balance] shortcode.
Front-End Display for Users:

Users can see their wallet balance and VIP level on the website where the shortcodes are implemented.
If not logged in, users are prompted to log in to view their information.
Important Notes and Considerations:
Admin-Centric Transactions:

The plugin assumes that all deposits and withdrawals are performed by an administrator through the WordPress admin dashboard.
There is no functionality for users to initiate deposits or withdrawals themselves (e.g., through payment gateways).
Security Measures:

Form Processing: The plugin processes form submissions in the admin dashboard without nonce verification. This could be a security risk (CSRF attacks). It's recommended to implement nonce checks for all form submissions.
Data Sanitization: User input from forms should be sanitized and validated to prevent SQL injection and other security vulnerabilities.
Database Efficiency:

Modifying the users table by adding columns (wallet_balance, vip_level) is not standard practice. It might be better to use user meta data (update_user_meta, get_user_meta) to store additional user information.
Extensibility:

The investment functionality is not fully fleshed out. The custom_investments table is created, but there are no functions that interact with it.
The plugin could be extended to handle user-initiated investments, returns, and more complex financial operations.
Error Handling and Feedback:

The plugin currently lacks user feedback mechanisms. For example, when an admin performs a deposit or VIP level change, there's no confirmation message.
Implementing messages or redirects after actions could improve usability.
Front-End Accessibility:

The plugin relies on shortcodes for front-end display. Ensure that these shortcodes are placed in appropriate pages or widgets for users to access their information.
Consider creating dedicated pages or a user dashboard for displaying wallet and VIP information.
Summary:
The Custom Referral & VIP Investment System plugin provides a basic framework for managing user referrals, VIP levels, and wallet balances within a WordPress site. It allows administrators to:

Track Referrals: Record when users are referred by others and store referral data.
Manage Wallets: Deposit into or withdraw from user wallets, affecting their wallet balances.
Calculate Commissions: Automatically award commissions to referrers when their referred users make significant deposits.
Adjust VIP Levels: Set and update users' VIP levels, which could be tied to specific privileges or features on the site.
Display User Information: Use shortcodes to show wallet balances and VIP levels to users on the front-end.
Potential Use Cases:
Investment Platforms: Sites where users invest money, and referrals are incentivized through commissions.
Membership Sites: Platforms that offer tiered memberships (VIP levels) with benefits for each tier.
Affiliate Programs: Businesses looking to implement a basic affiliate system with referral tracking and commission payouts.
Related categories: PHP WordPress MySQL Plugin WordPress Plugin