Get a Select User Meta Value

Support MB User Meta Get a Select User Meta Value

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5528
    socialitysociality
    Participant

    Hello!

    This is tricky. I have defined a select field as user meta. This is the array:

    
    			array(
    				'name' => esc_html__( 'Group Affiliation', 'colours-of-a-journey-plugin' ),
    				'id'   => $prefix . 'structure_group_affiliation',
    				'type' => 'select',
    				'options' => array(
    					'sel'	=> esc_html__( 'Select', 'colours-of-a-journey-plugin' ),
    					'pi'	=> esc_html__( 'Public Institution', 'colours-of-a-journey-plugin' ),
                        'ngo'	=> esc_html__( 'NGO', 'colours-of-a-journey-plugin' ),
                        'sos'	=> esc_html__( 'Self-Organized Structure', 'colours-of-a-journey-plugin' ),
                        'oth'	=> esc_html__( 'Other', 'colours-of-a-journey-plugin' ),
                    ),
    			),
    

    When I get the value through
    $user_structure_affiliation = get_user_meta( $curauth_id, 'colours_structure_group_affiliation', true );
    it returns the "sel", "pi", "ngo" values and not the ones I need, eg. Public Institution. I also tried the rwmb_the_value function with no luck. Any ideas?

    Thank you!

    #5541
    Anh TranAnh Tran
    Keymaster

    Hi,

    The function get_user_meta returns the values stored in the database. They are sel, pi, ngo. Please note that the text label is for showing to users to select only, they're not the values saved in the post meta.

    In this case, you can use a if-else check to output the correct label in the frontend.

    #5544
    socialitysociality
    Participant

    Alright,

    Thank you.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Get a Select User Meta Value’ is closed to new replies.