When calling Memberful_User_Map#map, it is possible for the compiler to raise a Undefined property warning when operating on deleted members. A few samples of the error are linked in the to-do.
This happens because the payload for deleted members from the Memberful API only returns the member id and a deleted property.
To-do: https://3.basecamp.com/3293071/buckets/5610905/card_tables/cards/6411081563
When calling
Memberful_User_Map#map
, it is possible for the compiler to raise aUndefined property
warning when operating on deleted members. A few samples of the error are linked in the to-do.This happens because the payload for deleted members from the Memberful API only returns the member
id
and adeleted
property.The errors happen in the following lines:
https://github.com/memberful/memberful-wp/blob/fde48841f661045be0e423ede192d7ff0a12d2a4/wordpress/wp-content/plugins/memberful-wp/src/user/map.php#L22
https://github.com/memberful/memberful-wp/blob/fde48841f661045be0e423ede192d7ff0a12d2a4/wordpress/wp-content/plugins/memberful-wp/src/user/map.php#L188-L194
This PR fixes the warning by checking whether the member is deleted in
Memberful_User_Map#map
.If a
WP_User
with the given memberid
exists, we return it immediately.If it doesn't exist, we return a
WP_Error
which is caught inmemberful_wp_sync_user
:https://github.com/memberful/memberful-wp/blob/fde48841f661045be0e423ede192d7ff0a12d2a4/wordpress/wp-content/plugins/memberful-wp/src/syncing.php#L45
I'm open to feedback or suggestions on fixing this differently. Thank you!