Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Resolved] Error message for WordPress administrator (wp_password_reset_hook)

Simple Membership Plugin › Forums › Simple Membership Plugin › Error message for WordPress administrator (wp_password_reset_hook)

  • This topic has 2 replies, 3 voices, and was last updated 7 years, 3 months ago by admin.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • August 6, 2019 at 11:05 am #18694
    John
    Participant

    A small error in sourcecode.

    The current version (3.8.3) has a small code error.

    It’s in the file at simple-membership/classes/class.simple-wp-membership.php

    That PHP file can be accessed in WP admin at
    <domain>/wp-admin/plugin-editor.php?file=simple-membership%2Fclasses%2Fclass.simple-wp-membership.php&plugin=simple-membership%2Fsimple-wp-membership.php

    
        function wp_password_reset_hook($user, $pass) {
            $swpm_id = SwpmUtils::get_user_by_user_name($user->user_login);
            if (!empty($swpm_id)) {
                $password_hash = SwpmUtils::encrypt_password($pass);
                global $wpdb;
                $wpdb->update($wpdb->prefix . "swpm_members_tbl", array('password' => $password_hash), array('member_id' => $swpm_id));
            }
        }

    The issue is when someone is using the site with their WordPress admin account and doing something that invokes wp_password_reset_hook.

    i.e. an account that was not created with SWPM registration form (e.g. Subscriber role), instead it was created inside WordPress dashboard directly (e.g. Administrator role, Editor role, etc).

    wp_password_reset_hook gets triggered but leads to a PHP error because the WordPress administrator/editor user is being looked up in the SWPM database tables and such a doesn’t exist there. The administrator/editor user is exclusive to WordPress internal wp_users table.

    This is a non-fatal error, but it when debugging is enabled (during dev phase, not for production), that PHP error text can be seen on the web page.

    The code fix to avoid the PHP error is:

    
        function wp_password_reset_hook($user, $pass) {
            $swpm_user = SwpmMemberUtils::get_user_by_user_name($user->user_login);
    
            if (empty($swpm_user)) {
                SwpmLog::log_auth_debug("[wp_password_reset_hook] - SWPM user not found for '" . $user->user_login 
            ."' - this is OK, assuming that this user was created directly in WP Dashboard", true);
                return;
            }
    
            $swpm_id = $swpm_user->member_id;
            if (!empty($swpm_id)) {
                $password_hash = SwpmUtils::encrypt_password($pass);
                global $wpdb;
                $wpdb->update($wpdb->prefix . "swpm_members_tbl", array('password' => $password_hash), array('member_id' => $swpm_id));
            }
        }
    August 6, 2019 at 12:10 pm #18695
    mbrsolution
    Moderator

    Hi, thank you for sharing your solution. I have submitted a message to the developers to investigate further your fix.

    Kind regards

    August 7, 2019 at 7:05 am #18700
    admin
    Keymaster

    Thank you. I have updated the code to fix this. It will go out with the next release.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy