Plugin Directory

Changeset 3345932


Ignore:
Timestamp:
08/17/2025 03:10:50 PM (8 months ago)
Author:
thevisad
Message:

Updating to 6.8.2 and Corrected issues with PMPro

Location:
hngamers-atavism-user-verification
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • hngamers-atavism-user-verification/tags/0.0.14/atavism-verify.php

    r3112739 r3345932  
    1212 * Plugin URI: https://hngamers.com/courses/atavism/atavism-wordpress-cms/
    1313 * Description:  This is the user verification plugin for the HNG Core Atavism series and allows users to verify and log into the game server from the wordpress logins.
    14  * Version: 0.0.12
     14 * Version: 0.0.14
    1515 * Author: thevisad
    1616 * Author URI: https://hngamers.com/
  • hngamers-atavism-user-verification/tags/0.0.14/readme.txt

    r3112739 r3345932  
    44Donate link: https://hngamers.com/support-and-thank-you/
    55Requires at least: 6.0
    6 Tested up to: 6.4.1
     6Tested up to: 6.8.2
    77Requires PHP: 7.4
    8 Stable tag: 0.0.12
     8Stable tag: 0.0.14
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3131
    3232== Changelog ==
     33= 0.0.14 =
     34Corrected issues with PMPro
     35
     36= 0.0.13 =
     37Patched issue with PMPro not working right.
     38
    3339= 0.0.12 =
    3440Updated to the new core handler.
  • hngamers-atavism-user-verification/tags/0.0.14/templates/hngamers-atavism-verify-user.php

    r3112739 r3345932  
    134134
    135135function hngamers_pmpro_integration($usernamePost, $userPassword) {
    136     $options = get_option('hngamers_atavism_user_verify_plugin_options');
    137     $required_pmpro_level = $options['pmp_subscription_id'];
    138     $pieces = explode(",", $required_pmpro_level);
     136    $opts = get_option('hngamers_atavism_user_verify_plugin_options');
     137    $required_levels = array_map('trim', explode(',', $opts['pmp_subscription_id']));
    139138
    140     if ( function_exists( 'pmpro_getMembershipLevelForUser' ))
    141     {
    142         $user = get_user_by( 'login', $usernamePost );
    143         $id = strval($user->ID);
    144         if ( empty( $id ) ) {
    145             echo(esc_html( '-1, user not found' ));
    146         }
    147         if (wp_check_password($userPassword, $user->data->user_pass, $id))
    148         {               
    149             $membership_level = pmpro_getMembershipLevelForUser( $user->ID );
    150             if ( empty( $membership_level ) ) {
    151                 echo(esc_html( '-1,  no subscription' ));
    152             } else {
    153                 $subscription = 0;
    154                 foreach ($pieces as &$value) {
    155                     if ( $membership_level->ID == $value)
    156                     {
    157                         hngamers_atavism_user_verify_check_wordpress_user($usernamePost, $userPassword);
    158                         $subscription = 1;
    159                         break;
    160                     }
    161                 }
    162                 if ($subscription == 0)
    163                 {
    164                     echo(esc_html( '-1,  no subscription.' ));     
    165                 }
    166             }
    167         }
    168         else
    169         {
    170             echo(esc_html( '-1,  wrong pass' ));
    171         }
    172     }
    173     else
    174     {
    175         echo(esc_html( '-1, required plugin not found' ));
    176     }
     139    if (! function_exists('pmpro_getMembershipLevelForUser')) {
     140        echo esc_html('-1, required plugin not found');
     141        return;
     142    }
     143
     144    // lookup WP user (handles email vs login)
     145    $user = ReturnWordPressUser($usernamePost);
     146    if (! $user) {
     147        echo esc_html('-1, user not found');
     148        return;
     149    }
     150
     151    // check password
     152    if (! wp_check_password($userPassword, $user->data->user_pass, $user->ID)) {
     153        echo esc_html('-1, wrong pass');
     154        return;
     155    }
     156
     157    // get the PMPro level (returns null or an object with ->id)
     158    $membership = pmpro_getMembershipLevelForUser($user->ID);
     159    if (empty($membership) || empty($membership->id)) {
     160        echo esc_html('-1, no subscription');
     161        return;
     162    }
     163
     164    foreach ($required_levels as $lvl) {
     165        if (intval($lvl) === intval($membership->id)) {
     166            // will echo the final user ID or banned code
     167            hngamers_atavism_user_verify_check_wordpress_user($usernamePost, $userPassword);
     168            return;
     169        }
     170    }
     171
     172    echo esc_html('-1, no subscription');
    177173}
  • hngamers-atavism-user-verification/trunk/atavism-verify.php

    r3112739 r3345932  
    1212 * Plugin URI: https://hngamers.com/courses/atavism/atavism-wordpress-cms/
    1313 * Description:  This is the user verification plugin for the HNG Core Atavism series and allows users to verify and log into the game server from the wordpress logins.
    14  * Version: 0.0.12
     14 * Version: 0.0.14
    1515 * Author: thevisad
    1616 * Author URI: https://hngamers.com/
  • hngamers-atavism-user-verification/trunk/readme.txt

    r3112739 r3345932  
    44Donate link: https://hngamers.com/support-and-thank-you/
    55Requires at least: 6.0
    6 Tested up to: 6.4.1
     6Tested up to: 6.8.2
    77Requires PHP: 7.4
    8 Stable tag: 0.0.12
     8Stable tag: 0.0.14
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3131
    3232== Changelog ==
     33= 0.0.14 =
     34Corrected issues with PMPro
     35
     36= 0.0.13 =
     37Patched issue with PMPro not working right.
     38
    3339= 0.0.12 =
    3440Updated to the new core handler.
  • hngamers-atavism-user-verification/trunk/templates/hngamers-atavism-verify-user.php

    r3112739 r3345932  
    134134
    135135function hngamers_pmpro_integration($usernamePost, $userPassword) {
    136     $options = get_option('hngamers_atavism_user_verify_plugin_options');
    137     $required_pmpro_level = $options['pmp_subscription_id'];
    138     $pieces = explode(",", $required_pmpro_level);
     136    $opts = get_option('hngamers_atavism_user_verify_plugin_options');
     137    $required_levels = array_map('trim', explode(',', $opts['pmp_subscription_id']));
    139138
    140     if ( function_exists( 'pmpro_getMembershipLevelForUser' ))
    141     {
    142         $user = get_user_by( 'login', $usernamePost );
    143         $id = strval($user->ID);
    144         if ( empty( $id ) ) {
    145             echo(esc_html( '-1, user not found' ));
    146         }
    147         if (wp_check_password($userPassword, $user->data->user_pass, $id))
    148         {               
    149             $membership_level = pmpro_getMembershipLevelForUser( $user->ID );
    150             if ( empty( $membership_level ) ) {
    151                 echo(esc_html( '-1,  no subscription' ));
    152             } else {
    153                 $subscription = 0;
    154                 foreach ($pieces as &$value) {
    155                     if ( $membership_level->ID == $value)
    156                     {
    157                         hngamers_atavism_user_verify_check_wordpress_user($usernamePost, $userPassword);
    158                         $subscription = 1;
    159                         break;
    160                     }
    161                 }
    162                 if ($subscription == 0)
    163                 {
    164                     echo(esc_html( '-1,  no subscription.' ));     
    165                 }
    166             }
    167         }
    168         else
    169         {
    170             echo(esc_html( '-1,  wrong pass' ));
    171         }
    172     }
    173     else
    174     {
    175         echo(esc_html( '-1, required plugin not found' ));
    176     }
     139    if (! function_exists('pmpro_getMembershipLevelForUser')) {
     140        echo esc_html('-1, required plugin not found');
     141        return;
     142    }
     143
     144    // lookup WP user (handles email vs login)
     145    $user = ReturnWordPressUser($usernamePost);
     146    if (! $user) {
     147        echo esc_html('-1, user not found');
     148        return;
     149    }
     150
     151    // check password
     152    if (! wp_check_password($userPassword, $user->data->user_pass, $user->ID)) {
     153        echo esc_html('-1, wrong pass');
     154        return;
     155    }
     156
     157    // get the PMPro level (returns null or an object with ->id)
     158    $membership = pmpro_getMembershipLevelForUser($user->ID);
     159    if (empty($membership) || empty($membership->id)) {
     160        echo esc_html('-1, no subscription');
     161        return;
     162    }
     163
     164    foreach ($required_levels as $lvl) {
     165        if (intval($lvl) === intval($membership->id)) {
     166            // will echo the final user ID or banned code
     167            hngamers_atavism_user_verify_check_wordpress_user($usernamePost, $userPassword);
     168            return;
     169        }
     170    }
     171
     172    echo esc_html('-1, no subscription');
    177173}
Note: See TracChangeset for help on using the changeset viewer.