I set up a Switch field on the user and set the ON label to “online” and the OFF label to “offline”. That works fine in the backend. But it produces inconsistent results on the frontend. I need to show the label of that field in different places on the frontend. I use Bricksbuilder with a query loop. Bricksbuilder can output Metabox fields automatically. But for Switch fields it only outputs the value which is 0 or 1 for Switch fields. To show the label I created a function:
function is_online() {
return rwmb_the_value('status',['object_type' => 'user'],get_queried_object_id());
}
Then I added the function to Bricksbuilder like this
{echo: is_online}
That outputs the label twice because Bricks echoes it and the rwmb_the_value as well.
When I change the function to use rwmb_get_value
it returns 0 or 1.
How can I get just the label without an additional echo via PHP?
Remark: I know that I can build a function with rwmb_get_value
and use an if then statement, but that would cause me to keep the label in the custom field and the function in sync.