{"id":18600529,"date":"2025-08-15T14:11:11","date_gmt":"2025-08-15T14:11:11","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/erasure\/"},"modified":"2025-08-15T14:11:11","modified_gmt":"2025-08-15T14:11:11","slug":"erasure","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/erasure\/","title":{"rendered":"Erasure"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Vanilla data erasure feature issue:\u2014<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">The problem is that the plugin expects a non-false return value from delete_user_meta(), but delete_user_meta() returns<br \/>false if the meta doesn&#8217;t exist (which is normal for users who may not have all meta fields set).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The plugin&#8217;s logic is flawed &#8211; it reports an &#8220;error&#8221; when trying to delete meta that doesn&#8217;t exist, which is actually the desired state for<br \/>GDPR compliance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s the issue:<\/p>\n\n\n\n<ul>\n<li>delete_user_meta() returns false if the meta key doesn&#8217;t exist<\/li>\n\n\n\n<li>The plugin treats this as an error and shows the &#8220;unable to be removed&#8221; message<\/li>\n\n\n\n<li>But if the meta doesn&#8217;t exist, that means the data is already &#8220;erased&#8221;<\/li>\n<\/ul>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>\u2502 wp-content\/plugins\/when-last-login\/includes\/privacy-policy.php                                                                                \u2502 \u2502<br \/>\u2502 \u2502                                                                                                                                               \u2502 \u2502<br \/>\u2502 \u2502   141      $items_retained = false;                                                                                                           \u2502 \u2502<br \/>\u2502 \u2502   142      if ( $user &amp;&amp; $user-&gt;ID ) {                                                                                                        \u2502 \u2502<br \/>\u2502 \u2502   143                                                                                                                                         \u2502 \u2502<br \/>\u2502 \u2502   144 -      $deleted_when_last_login = delete_user_meta( $user-&gt;ID, 'when_last_login' );                                                     \u2502 \u2502<br \/>\u2502 \u2502   145 -      if ( $deleted_when_last_login ) {                                                                                                \u2502 \u2502<br \/>\u2502 \u2502   146 -        $items_removed = true;                                                                                                         \u2502 \u2502<br \/>\u2502 \u2502   147 -      } else {                                                                                                                         \u2502 \u2502<br \/>\u2502 \u2502   148 -        $messages&#091;] = __( 'Your last login timestamp was unable to be removed at this time.', 'when-last-login' );                     \u2502 \u2502<br \/>\u2502 \u2502   149 -        $items_retained = true;                                                                                                        \u2502 \u2502<br \/>\u2502 \u2502   144 +      \/\/ Check if meta exists before trying to delete                                                                                  \u2502 \u2502<br \/>\u2502 \u2502   145 +      $existing_login = get_user_meta( $user-&gt;ID, 'when_last_login', true );                                                           \u2502 \u2502<br \/>\u2502 \u2502   146 +      if ( $existing_login ) {                                                                                                         \u2502 \u2502<br \/>\u2502 \u2502   147 +        $deleted_when_last_login = delete_user_meta( $user-&gt;ID, 'when_last_login' );                                                   \u2502 \u2502<br \/>\u2502 \u2502   148 +        if ( $deleted_when_last_login ) {                                                                                              \u2502 \u2502<br \/>\u2502 \u2502   149 +          $items_removed = true;                                                                                                       \u2502 \u2502<br \/>\u2502 \u2502   150 +        } else {                                                                                                                       \u2502 \u2502<br \/>\u2502 \u2502   151 +          $messages&#091;] = __( 'Your last login timestamp was unable to be removed at this time.', 'when-last-login' );                   \u2502 \u2502<br \/>\u2502 \u2502   152 +          $items_retained = true;                                                                                                      \u2502 \u2502<br \/>\u2502 \u2502   153 +        }                                                                                                                              \u2502 \u2502<br \/>\u2502 \u2502   154        }                                                                                                                                \u2502 \u2502<br \/>\u2502 \u2502   155 +      \/\/ If meta doesn't exist, that's fine - data is already \"erased\"  <\/code><\/pre>\n","protected":false},"template":"","class_list":["post-18600529","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18600529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18600529\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18600529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}