I loaded the Membership API and I’m getting NULL values for some fields

API provides other values and is working fine, but the things I need - it's NULL. I get user ID's and membership statuses, but I’m getting null values for username, email, name, first_name, last_name, password and password2.

  • Ash

    Hello justin

    I will need a bit details about this query, I hope you will help me :slight_smile:

    Please let me know how and when you want to fetch the data using M2 API? Are you using any external plugin? What are the codes you are using and how (as a plugin or functions.php etc)? Please let me know the details including your codes and I will set that up on my test site to fund the issue; therefore, I can send you a solution :slight_smile:

    Have a nice day!

    Cheers,
    Ash

    • justin

      Hey there, Ash,

      we found an issue actually. It was in the class-ms-factory.php file, lines 420-425. We don’t know why, but you guys unset the member values ¯\_(?)_/¯

      // // Remove automatic populated values from metadata, if present.
      unset( $member_details['ms_username'] );
      unset( $member_details['ms_email'] );
      unset( $member_details['ms_name'] );
      unset( $member_details['ms_first_name'] );
      unset( $member_details['ms_last_name'] );

      So I commented out the lines and API returns normal values instead of null. So all is working fine now.
      Anyway, the question is why you need to unset these values? We dig the code only for couple of hours so as you can expect we don't know a lot of things about the logic behind the functions ¯\_(?)_/¯

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.