WordPress.org

Ready to get started?Download WordPress

Forums

Get_user_meta not working in my plugin (2 posts)

  1. maheshwarimani1991
    Member
    Posted 5 months ago #

    i am using get_user_meta() function in my plugin but it is not showing any values for usermeta table, it is showing blank result.

    I am able to see the value present in phpmyadmin. I am using it in a plugin add_action('user_register','user_sf_lead'), but it is not showing any value in my code.

    I am able get all the value of USER table but no values from USERMETA table in my plugin.

    When updating my user i am able to get all values.

    How to get values from get_user_meta while using action hook
    add_action('user_register','user_sf_lead')

    Also when get_userdata , i getting values from USER table but not from USERMETA table.

    $user_info = get_userdata($user_id);
    'Name' => $user_info->ID,
    'First_Name__c' => $user_info->first_name,

    Provide solution??

  2. bcworkz
    Member
    Posted 5 months ago #

    It sounds like a cache somewhere is not getting updated. When you add user metadata, WP deletes the old associated cache, forcing a refresh when you use get_user_meta(). There could be other caches in play, perhaps placed by your host. If you cannot determine how to refresh all caches involved, go straight to the DB and get the data using $wpdb methods. Not as efficient as caches, but more reliable.

Reply

You must log in to post.

About this Topic