BP_XProfile_Field::get_id_from_name( string $field_name = '' )
Get field ID from field name.
Description
Parameters
- $field_name
-
(Optional) Name of the field to query the ID for.
Default value: ''
Return
(int|null) Field ID on success; null on failure.
Source
File: bp-xprofile/classes/class-bp-xprofile-field.php
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | public static function get_id_from_name( $field_name = '' ) { global $wpdb ; $bp = buddypress(); if ( empty ( $bp ->profile->table_name_fields ) || empty ( $field_name ) ) { return false; } $id = bp_core_get_incremented_cache( $field_name , 'bp_xprofile_fields_by_name' ); if ( false === $id ) { $sql = $wpdb ->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s AND parent_id = 0" , $field_name ); $id = $wpdb ->get_var( $sql ); bp_core_set_incremented_cache( $field_name , 'bp_xprofile_fields_by_name' , $id ); } return is_numeric ( $id ) ? (int) $id : $id ; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.5.0 | Introduced. |
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.