A WordPress plugin for managing users in the Cool Kids Network game.
Cool Kids Network is a WordPress plugin that provides a user management system for a fictional game. It allows users to sign up with just an email address, automatically generates character profiles, and implements a role-based permission system.
Website for access projects. https://wpmeet.in/rankmath-test/
- Simple Signup Process: Users can register with just an email address
- Character Generation: Automatically generates character profiles using the RandomUser API
- Role-Based Permissions: Three user roles with different capabilities:
- Cool Kid (basic access)
- Cooler Kid (can view character details)
- Coolest Kid (can view sensitive info and edit roles)
- User Listing: Display all users with filtering based on user role
- REST API: Endpoints for managing user roles
- Shortcodes: Easy integration with WordPress pages
- Upload the
cool-kids-networkfolder to the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Create pages for signup, login, character profile, and user listing
- Add the appropriate shortcodes to each page
The plugin provides the following shortcodes:
[cool_kids_signup]- Displays the signup form[cool_kids_login]- Displays the login form[character_profile]- Displays the current user's character profile[user_listing]- Displays a list of all users in the network
Create a page titled "Signup" and add the shortcode:
[cool_kids_signup]
Create a page titled "Login" and add the shortcode:
[cool_kids_login]
Create a page titled "My Character" and add the shortcode:
[character_profile]
Create a page titled "Network Members" and add the shortcode:
[user_listing]
- Basic access to the site
- Can view their own character profile
- Can see limited information in the user listing
- All Cool Kid capabilities
- Can view additional character details
- Can see email addresses in the user listing
- All Cooler Kid capabilities
- Can view sensitive information
- Can edit character roles through the API
- Can see all user information in the listing
The plugin provides a REST API endpoint for managing user roles:
Endpoint: /wp-json/cool-kids-network/v1/assign-role
Method: POST
Parameters:
email: The email address of the user to updatefirst_name: The first name of the user to updatelast_name: The last name of the user to updaterole(required): The new role to assign (cool_kid, cooler_kid, or coolest_kid)
Note: You must provide either an email address OR both first and last names to identify the user.
Authentication:
- Requires administrator privileges
Example Request using Email:
curl -X POST \
'https://example.com/wp-json/cool-kids-network/v1/assign-role' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your_generated_jwt_token' \
-d '{
"email": "[email protected]",
"role": "cooler_kid"
}'Example Request using Name:
curl -X POST \
'https://example.com/wp-json/cool-kids-network/v1/assign-role' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your_generated_jwt_token' \
-d '{
"first_name": "John",
"last_name": "Doe",
"role": "cooler_kid"
}'Example Response:
{
"success": true,
"message": "Role updated successfully."
}- Log in to your WordPress site as an administrator
- Generate JWT Token for Authentication.
https://yourwebsite.com/wp-json/jwt-auth/v1/tokenwith Body (raw JSON format):{ "username": "admin", "password": "your_admin_password" } - Create a new request in Postman:
- Method: POST
- URL:
https://your-site.com/wp-json/cool-kids-network/v1/assign-role - Headers:
- Content-Type: application/json
- Authorization: Bearer your_generated_jwt_token
- Body (raw JSON):
{ "email": "[email protected]", "role": "cooler_kid" } - Or alternatively:
{ "first_name": "John", "last_name": "Doe", "role": "cooler_kid" }
- Send the request
- PHP 7.4 or higher
- WordPress 5.0 or higher
The plugin includes PHPUnit tests for the main functionality. To run the tests:
- Set up the WordPress test environment
- Run
composer installto install dependencies - Run
composer testto execute the test suite
The plugin follows the WordPress Coding Standards. To check compliance:
composer phpcs
To automatically fix coding standards issues:
composer phpcbf
cool-kids-network/
├── assets/
│ └── css/
│ └── style.css # Plugin styles
├── includes/
│ ├── class-api.php # REST API functionality
│ ├── class-character-generator.php # Character generation logic
│ ├── class-cool-kids-network.php # Main plugin class
│ └── class-user-roles.php # User role management
├── templates/
│ ├── character-profile.php # Character profile template
│ ├── login-form.php # Login form template
│ ├── signup-form.php # Signup form template
│ └── user-listing.php # User listing template
├── tests/
│ ├── bootstrap.php # Test bootstrap file
│ ├── test-api.php # API tests
│ ├── test-character-generator.php # Character generator tests
│ └── test-user-roles.php # User roles tests
├── composer.json # Composer configuration
├── cool-kids-network.php # Main plugin file
├── phpcs.xml # PHP CodeSniffer configuration
├── phpunit.xml # PHPUnit configuration
└── README.md # This file
cool_kids_network_user_registered- Fired when a new user is registeredcool_kids_network_user_login- Fired when a user logs in
cool_kids_network_character_data- Filter character data before savingcool_kids_network_user_roles- Filter available user roles
Users log in using only their email address. No password is required for simplicity.
Character profiles are generated using the RandomUser API. If the API is unavailable, the plugin falls back to a set of predefined names and countries.
Yes, you can use the cool_kids_network_user_roles filter to modify the available roles and their capabilities.
This plugin is licensed under the GPL v2 or later.
- RandomUser API: https://randomuser.me/
- WordPress Plugin Boilerplate: https://github.com/DevinVinson/WordPress-Plugin-Boilerplate