Category as options for dropdown/select/multiselect

add_filter( 'user_meta_field_config', 'user_meta_field_config_populate_categories', 10, 3 );
function user_meta_field_config_populate_categories( $field, $fieldID, $formName ){ 
 
    if( $fieldID != 'Your_Field_ID' ) // Put your desired field id here
        return $field;
 
    $output = null;
    $cats = get_categories();
    foreach( $cats as $cat ):
        $output .= $cat->term_id.'='.$cat->name.',';
    endforeach;
    $output = ',' . trim( $output, ',' );
 
    $field['options'] = $output;
 
    return $field;
}

Leave a Reply

Subscribe to our newsletter