Skip Navigation

[Resolved] Display and Evaluate Custom User Meta

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 5 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#1259747

Tell us what you are trying to do?

My "Select" type field returns the value rather then the label/text:

$key = 'wpcf-type';
$single = true;
$user_type = get_user_meta( $user_id, $key, $single );

return $user_type;
}

Is it possible to return the label?

In addition how could I evaluate the select field based on the text not values e.g.

if ( type = Male ) { } ifelse (type = Female) {} else { ""}

#1259971

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - to access the user meta field - Types offers PHP API function:

For example:

$user_type  = types_render_usermeta( "type", array('user_id'=>$user_id));

If($user_type == 'Male'){
  // add something
} else If($user_type == 'Female'){
  // add something
}

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#select