xprofile_check_gender_added_previously()
Check if the gender field has been added.
Description
Source
File: bp-xprofile/bp-xprofile-admin.php
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 | function xprofile_check_gender_added_previously() { global $wpdb ; $response = array (); $response [ 'message' ] = __( 'You can only have one instance of the "Gender" profile field.' , 'buddyboss' ); $referer = filter_input( INPUT_POST, 'referer' , FILTER_SANITIZE_STRING ); parse_str ( $referer , $parsed_array ); if ( 'edit_field' === $parsed_array [ 'mode' ] ) { $current_edit_id = intval ( $parsed_array [ 'field_id' ] ); $exists_gender = $wpdb ->get_results( "SELECT COUNT(*) as count, id FROM {$wpdb->prefix}bp_xprofile_fields a WHERE parent_id = 0 AND type = 'gender' " ); if ( intval ( $exists_gender [0]-> count ) > 0 ) { if ( $current_edit_id === intval ( $exists_gender [0]->id ) ) { $response [ 'status' ] = 'not_added' ; } else { $response [ 'status' ] = 'added' ; } } else { $response [ 'status' ] = 'not_added' ; } } else { $exists_gender = $wpdb ->get_results( "SELECT COUNT(*) as count, id FROM {$wpdb->prefix}bp_xprofile_fields a WHERE parent_id = 0 AND type = 'gender' " ); if ( intval ( $exists_gender [0]-> count ) > 0 ) { $response [ 'status' ] = 'added' ; } else { $response [ 'status' ] = 'not_added' ; } } echo wp_json_encode( $response ); wp_die(); } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.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.