BP_REST_XProfile_Types_Endpoint::bp_rest_member_type_post_by_type( string $member_type )
Get Member post by profile type.
Description
Parameters
- $member_type
-
(Required) Member type name.
Return
(array)
Source
File: bp-xprofile/classes/class-bp-rest-xprofile-types-endpoint.php
protected function bp_rest_member_type_post_by_type( $member_type ) { if ( empty( $member_type ) ) { return; } global $wpdb; // phpcs:disable $query = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '%s' AND LOWER(meta_value) = '%s'"; $query = $wpdb->prepare( $query, '_bp_member_type_key', $member_type ); $post_id = $wpdb->get_var( $query ); // Fallback to legacy way to retrieve profile type from name by using singular label. if ( ! $post_id ) { $name = str_replace( array( '-', '-' ), array( ' ', ',' ), $member_type ); $query = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '%s' AND LOWER(meta_value) = '%s'"; $query = $wpdb->prepare( $query, '_bp_member_type_label_singular_name', $name ); $post_id = $wpdb->get_var( $query ); } // phpcs:enable return apply_filters( 'bp_member_type_post_by_type', $post_id ); }
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.