0

How to pass the custom field values which were stored while creating a new user into the wp_get_current_user array function

When I call the wp_get_current_user() function the result which I found is as follows:

WP_User Object
(
    [data] => stdClass Object
        (
            [ID] => 20
            [user_login] => testing
            [user_pass] => $P$BAfSwYFZEUKIkQyF30Eq7GN3HOUXFW/
            [user_nicename] => testing
            [user_email] => testing@testing.com
            [user_url] => 
            [user_registered] => 2015-12-15 07:11:35
            [user_activation_key] => 1450163495:$P$Br7QHNREuY.esEZdB3c92fK2CrW9QH.
            [user_status] => 0
            [display_name] => testing testing
            [token_key] => 
        )

    [ID] => 20
    [caps] => Array
        (
            [subscriber] => 1
        )

    [cap_key] => wp_capabilities
    [roles] => Array
        (
            [0] => subscriber
        )

    [allcaps] => Array
        (
            [read] => 1
            [level_0] => 1
            [subscriber] => 1
        )

    [filter] => 
)

But I want the answer to be as

WP_User Object
    (
        [data] => stdClass Object
            (
                [ID] => 20
                [user_login] => testing
                [user_pass] => $P$BAfSwYFZEUKIkQyF30Eq7GN3HOUXFW/
                [user_nicename] => testing
                [user_email] => testing@testing.com
                [user_url] => 
                [user_registered] => 2015-12-15 07:11:35
                [user_activation_key] => 1450163495:$P$Br7QHNREuY.esEZdB3c92fK2CrW9QH.
                [user_status] => 0
                [display_name] => testing testing
                [token_key] => 
                [client] => abc
                [user_groups] => test
            )

        [ID] => 20
        [caps] => Array
            (
                [subscriber] => 1
            )

        [cap_key] => wp_capabilities
        [roles] => Array
            (
                [0] => subscriber
            )

        [allcaps] => Array
            (
                [read] => 1
                [level_0] => 1
                [subscriber] => 1
            )

        [filter] => 
    )

Compare the [data] part of both the array

How do I achieve this?

Thanks for the help in advance

0

I found the answer for my question. No need to pass the values in the array we can call the separate function to get the values of the custom fields based on the current user for e.g. get_user_meta($current->ID);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.