Get current user attribute value

I use this code to create a shortcode in order to get the current user’s last name

// [current_user_display_last_name]
function display_current_user_last_name () {
$user = wp_get_current_user();
$last_name= $user->last_name;
return $user->last_name;
add_shortcode(‘current_user_last_name’, ‘display_current_user_last_name’);

is it possible to get the value of a specific attibute for the current vendor?

It is possible to get vendor attribute value in this way

$vendor = \HivePress\Models\Vendor::query()->filter(['user' => get_current_user_id()])->get_first();


Thank you yevhen, it works perfectly for text attributes.
Is it possible to get the same for “select” attributes (multi option)s) ?

If I use the same code, it returns “Array” for select fields…


Do you have any idea to solve that issue?

I’m sorry for the delay. Yes, for selectable attributes there’s an array of selected options, you can iterate over them and get their label if needed via the get_name method. You can also display comma-separated labels this way:


Hope this helps.

Thanks ihor, it works perfectly

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.