/** * Add custom fields to BuddyPress Member Type taxonomy labels * * This function extends the existing member type labels to include * our custom fields for Badge Color and Icon. * * @since 1.0.0 * @param array $fields Array of existing member type fields * @return array Modified array with custom fields added */ function wbcom_bp_add_member_type_custom_fields( $fields ) { $fields['bp_member_type_badge_color'] = _x( 'Badge Color', 'BP Member type badge color label', 'wbcom-member-type-extension' ); $fields['bp_member_type_icon'] = _x( 'Icon', 'BP Member type icon label', 'wbcom-member-type-extension' ); return $fields; } add_filter( 'bp_get_member_type_tax_labels', 'wbcom_bp_add_member_type_custom_fields' ); /** * Add custom fields to BuddyPress Member Type metadata schema * * This function registers our custom fields in the BuddyPress metadata schema * so they are properly handled by the BuddyPress type system. * * @since 1.0.0 * @param array $schema The existing metadata schema * @param string $taxonomy The taxonomy name being processed * @return array Modified schema with custom fields added */ function wbcom_bp_add_member_type_metadata_schema( $schema = array(), $taxonomy = '' ) { if ( bp_get_member_type_tax_name() === $taxonomy ) { // Badge Color field schema $schema['bp_member_type_badge_color'] = array( 'description' => __( 'Choose a color for member type badges.', 'wbcom-member-type-extension' ), 'type' => 'string', 'single' => true, 'sanitize_callback' => 'sanitize_hex_color', ); // Icon field schema $schema['bp_member_type_icon'] = array( 'description' => __( 'Icon class (e.g., fa-user) or image URL.', 'wbcom-member-type-extension' ), 'type' => 'string', 'single' => true, 'sanitize_callback' => 'sanitize_text_field', ); } return $schema; } add_filter( 'bp_get_type_metadata_schema', 'wbcom_bp_add_member_type_metadata_schema', 10, 2 ); /** * Add custom fields to the member type add form * * This function adds our custom fields to the "Add New Member Type" form * in the WordPress admin area. * * @since 1.0.0 * @param string $taxonomy The taxonomy name */ function wbcom_bp_member_type_add_form_custom_fields( $taxonomy ) { ?>