3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * Plugin Name: CNMG Shop Ghana MLM Hierarchy * Plugin URI: https://example.com/cnmg-mlm * Description: Custom MLM registration system for CNMG Shop Ghana district hierarchy (District Aggregator → Zonal Agents → Community Agents). * Version: 1.0.0 * Author: Grok by xAI * License: GPL-2.0+ */ // If this file is called directly, abort. if ( ! defined( 'WPINC' ) ) { die; } define( 'CNMG_MLM_VERSION', '1.0.0' ); define( 'CNMG_MLM_PATH', plugin_dir_path( __FILE__ ) ); define( 'CNMG_MLM_URL', plugin_dir_url( __FILE__ ) ); /* === Activate: Create Custom Roles === */ function cnmg_mlm_activate() { add_role( 'district_aggregator', 'District Aggregator', array( 'read' => true ) ); add_role( 'zonal_agent', 'Zonal Agent', array( 'read' => true ) ); add_role( 'community_agent', 'Community Agent', array( 'read' => true ) ); } register_activation_hook( __FILE__, 'cnmg_mlm_activate' ); /* === User Profile Fields === */ function cnmg_mlm_user_profile_fields( $user ) { ?> <h3>CNMG MLM Hierarchy Info</h3> <table class="form-table"> <tr> <th><label>Sponsor ID</label></th> <td><input type="text" name="sponsor_id" value="<?php echo esc_attr( get_user_meta( $user->ID, 'sponsor_id', true ) ); ?>" class="regular-text" /></td> </tr> <tr> <th><label>Agent Type</label></th> <td> <select name="agent_type"> <option value="district_aggregator" <?php selected( get_user_meta( $user->ID, 'agent_type', true ), 'district_aggregator' ); ?>>District Aggregator</option> <option value="zonal_agent" <?php selected( get_user_meta( $user->ID, 'agent_type', true ), 'zonal_agent' ); ?>>Zonal Agent</option> <option value="community_agent" <?php selected( get_user_meta( $user->ID, 'agent_type', true ), 'community_agent' ); ?>>Community Agent</option> </select> </td> </tr> <tr> <th><label>District</label></th> <td><input type="text" name="district" value="<?php echo esc_attr( get_user_meta( $user->ID, 'district', true ) ); ?>" class="regular-text" /></td> </tr> <tr> <th><label>Zone</label></th> <td><input type="text" name="zone" value="<?php echo esc_attr( get_user_meta( $user->ID, 'zone', true ) ); ?>" class="regular-text" /></td> </tr> </table> <?php } add_action( 'show_user_profile', 'cnmg_mlm_user_profile_fields' ); add_action( 'edit_user_profile', 'cnmg_mlm_user_profile_fields' ); function cnmg_mlm_save_user_profile( $user_id ) { if ( ! current_user_can( 'edit_user', $user_id ) ) return; update_user_meta( $user_id, 'sponsor_id', sanitize_text_field( $_POST['sponsor_id'] ?? '' ) ); update_user_meta( $user_id, 'agent_type', sanitize_text_field( $_POST['agent_type'] ?? '' ) ); update_user_meta( $user_id, 'district', sanitize_text_field( $_POST['district'] ?? '' ) ); update_user_meta( $user_id, 'zone', sanitize_text_field( $_POST['zone'] ?? '' ) ); } add_action( 'personal_options_update', 'cnmg_mlm_save_user_profile' ); add_action( 'edit_user_profile_update', 'cnmg_mlm_save_user_profile' ); /* === Registration Form Shortcode === */ function cnmg_mlm_registration_form() { ob_start(); ?> <form method="post" style="max-width:600px; margin:30px auto; padding:20px; border:1px solid #ddd;"> <?php wp_nonce_field( 'cnmg_register', 'cnmg_nonce' ); ?> <p><label>Username<br><input type="text" name="username" required style="width:100%;"></label></p> <p><label>Email<br><input type="email" name="email" required style="width:100%;"></label></p> <p><label>Password<br><input type="password" name="password" required style="width:100%;"></label></p> <p><label>Sponsor ID<br><input type="text" name="sponsor_id" required style="width:100%;"></label></p> <p><label>Agent Type<br> <select name="agent_type" required style="width:100%;"> <option value="community_agent">Community Agent</option> <option value="zonal_agent">Zonal Agent</option> <option value="district_aggregator">District Aggregator</option> </select> </label></p> <p><label>District<br><input type="text" name="district" required style="width:100%;"></label></p> <p><label>Zone (optional)<br><input type="text" name="zone" style="width:100%;"></label></p> <input type="submit" name="cnmg_register" value="Register as Agent" style="padding:10px 20px;"> </form> <?php return ob_get_clean(); } add_shortcode( 'cnmg_registration_form', 'cnmg_mlm_registration_form' ); /* === Handle Registration === */ function cnmg_mlm_handle_registration() { if ( ! isset( $_POST['cnmg_register'] ) || ! wp_verify_nonce( $_POST['cnmg_nonce'], 'cnmg_register' ) ) { return; } $username = sanitize_user( $_POST['username'] ); $email = sanitize_email( $_POST['email'] ); $password = $_POST['password']; $sponsor_id = sanitize_text_field( $_POST['sponsor_id'] ); $agent_type = sanitize_text_field( $_POST['agent_type'] ); $district = sanitize_text_field( $_POST['district'] ); $zone = sanitize_text_field( $_POST['zone'] ); if ( username_exists( $username ) || email_exists( $email ) ) { echo '<p style="color:red;">Username or email already exists.</p>'; return; } $user_id = wp_create_user( $username, $password, $email ); if ( is_wp_error( $user_id ) ) { echo '<p style="color:red;">' . $user_id->get_error_message() . '</p>'; return; } $user = new WP_User( $user_id ); $user->set_role( $agent_type ); update_user_meta( $user_id, 'sponsor_id', $sponsor_id ); update_user_meta( $user_id, 'agent_type', $agent_type ); update_user_meta( $user_id, 'district', $district ); update_user_meta( $user_id, 'zone', $zone ); echo '<p style="color:green; font-weight:bold;">Registration successful! Your Agent ID is: <strong>' . $user_id . '</strong></p>'; } add_action( 'template_redirect', 'cnmg_mlm_handle_registration' );

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.80.0120.00416.54
8.5.70.0140.00316.64
8.5.60.0170.00416.64
8.5.50.0160.00416.65
8.5.40.0160.00716.61
8.5.30.0160.00516.47
8.5.20.0180.00316.77
8.5.10.0180.00216.50
8.5.00.0070.00316.64
8.4.230.0170.00419.64
8.4.220.0170.00319.48
8.4.210.0170.00621.11
8.4.200.0190.00319.73
8.4.190.0150.00519.52
8.4.180.0210.00419.46
8.4.170.0180.00519.61
8.4.160.0210.00419.59
8.4.150.0200.00419.44
8.4.140.0160.00617.70
8.4.130.0160.00417.63
8.4.120.0190.00517.61
8.4.110.0190.00417.79
8.4.100.0170.00417.86
8.4.90.0180.00417.82
8.4.80.0160.00517.77
8.4.70.0240.00317.86
8.4.60.0190.00417.78
8.4.50.0140.00617.78
8.4.40.0210.00217.59
8.4.30.0170.00719.18
8.4.20.0230.00317.75
8.4.10.0200.00417.62
8.3.320.0040.00618.63
8.3.310.0180.00518.63
8.3.300.0140.00818.36
8.3.290.0150.00618.35
8.3.280.0170.00418.37
8.3.270.0200.00416.67
8.3.260.0170.00416.81
8.3.250.0150.00616.82
8.3.240.0130.00916.80
8.3.230.0160.00416.55
8.3.220.0180.00416.70
8.3.210.0160.00416.65
8.3.200.0180.00216.67
8.3.190.0200.00416.76
8.3.180.0180.00516.45
8.3.170.0180.00416.68
8.3.160.0160.00716.81
8.3.150.0200.00316.58
8.3.140.0170.00816.50
8.3.130.0160.00516.51
8.3.120.0140.00616.79
8.3.110.0140.00616.68
8.3.100.0170.00616.85
8.3.90.0170.00616.65
8.3.80.0180.00516.79
8.3.70.0190.00416.55
8.3.60.0180.00516.84
8.3.50.0160.00616.59
8.3.40.0170.00617.80
8.3.30.0150.00417.69
8.3.20.0140.00517.75
8.3.10.0140.00517.82
8.3.00.0130.00617.92
8.2.320.0170.00417.89
8.2.310.0140.00818.20

preferences:
62.23 ms | 758 KiB | 5 Q