• Resolved riille

    (@riille)


    Hi,

    I’m using a social media plugin for login and registration. This plugin puts data that I don’t want into the user’s meta data.

    So my no-working-solution that I have tried is that I run this code by hooking into the “user_register” hook. Trying to delete the data when the plugin registers the user.

    delete_user_meta($user_id, "shipping_first_name");
        delete_user_meta($user_id, "billing_first_name");

    But the user meta data won’t get deleted by doing this.

    If I execute the exact same code in another context (for example by clicking a menu button) the code works fine and the user’s meta data will be deleted.

    How do I delete these user meta data at registration?

    Thanks!

    //Rickard

Viewing 2 replies - 1 through 2 (of 2 total)
  • hi, it might be that the meta is not yet saved by the time the hook is called, the hook’s manual page explains:

    Not all user meta data has been stored in the database when this action is triggered. For example, nickname is in the database but first_name and last_name are not (as of 3.9.1).

    It is important to know when the social plugin sets the user meta to be able to find the right hook to use. Which social media plugin is it?

    Thread Starter riille

    (@riille)

    Hi again, thanks for your help. You were right. I solved this by delete the user meta data with the code lines I showed earlier at the very first login. At that point the meta data was saved and could be deleted.

    https://wp-mix.com/wordpress-first-user-login/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Delete user meta data at user registration’ is closed to new replies.