Tagged: Age, Xprofile Fields
I just installed BuddyPress Xprofile Custom Field Types to replace the old BuddyPress Xprofile Custom Fields Type, but I noticed that the months are displayed when show age is selected. So for instance I’m 35 years old and my profile says I’m 35 years and 3 months. I don’t want the 3 months to show. Is there a way to get rid of that? BTW thanks for creating a replacement to the old plugin. I knew the old plugin was not compatible with Buddypress 3.0 and it prevented me from updating.
- This topic was modified 6 years, 6 months ago by Keith.
Hello Keith,
Thank you for posting. Please try the following code in your bp-custom.php file and let me know if it works or not.
/** * Modify birth date output * * @param string $age Age. * @param int $field_id Field id. * * @return array */ function buddydev_modify_birth_date_data( $age, $field_id ) { if ( ! bp_is_user() || ! bp_xprofile_get_meta( $field_id, 'field', 'show_age', true ) ) { return $age; } if ( strpos( $age, ',' ) != false ) { $age = explode( ',', $age ); return $age[0]; }; return $age; } add_filter( 'bpxcftr_birthdate_age_display_data', 'buddydev_modify_birth_date_data', 10, 2 );
Thank You
RaviThank you Ravi.
In future, I am adding the option in the field settings to ask the admins if they want to show the month or not. That way, It will be much simpler.
Bets regards
BrajeshHi Keith,
You may remove the code after upgrading to 1.0.1BuddyPress Xprofile Custom Field Types 1.0.1 is available and it provides you an option on the Admin edit field page to show/hide month.
Best Regards
Brajesh
The topic ‘ [Resolved] BuddyPress Xprofile Custom Field Types Age’ is closed to new replies.