BP_XProfile_Field::get_type( int $field_id )

Get the type for provided field ID.

Description

Parameters

$field_id

(Required) Field ID to get type of.

Return

(bool|null|string)

Source

File: bp-xprofile/classes/class-bp-xprofile-field.php

939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
public static function get_type( $field_id = 0 ) {
    global $wpdb;
 
    // Bail if no field ID.
    if ( empty( $field_id ) ) {
        return false;
    }
 
    $bp   = buddypress();
    $sql  = $wpdb->prepare( "SELECT type FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id );
    $type = $wpdb->get_var( $sql );
 
    // Return field type.
    if ( ! empty( $type ) ) {
        return $type;
    }
 
    return false;
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.