Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get all options from custom profile field


  • handyandywilson
    Participant

    @handyandywilson

    Hey guys,

    I am trying to get all options associated to a field without being assigned to a user. I know bp_get_profile_field_data( array('user_id'=>$current_user_id,'field'=>'fieldabc' )); grabs the user data, but how could I do this for retreiving all options associated to a custom profile field?

    I.e. fieldabc has checkbox 1, 2, 3
    user ID has checkbox 1 from fieldabc.
    What I want is to return all checkbox fields from fieldabc.

    Cheers,

    Andrew

Viewing 1 replies (of 1 total)

  • ckchaudhary
    Participant

    @ckchaudhary

    function wdw_bp_get_field_options( $field_id ){
    	global $bp, $wpdb;
    	return $wpdb->get_col( $wpdb->prepare( "SELECT name FROM {$bp->profile->table_name_fields} WHERE parent_id=%d AND type='option'", $field_id ) );
    }

    You can call the above function passing id of the field( fieldabc in your example ). This will return all options of the field in an array.

Viewing 1 replies (of 1 total)
  • The topic ‘Get all options from custom profile field’ is closed to new replies.
Skip to toolbar