Forum Replies Created
-
add_filter(‘show_admin_bar’, ‘__return_false’);
In that code your
'
‘s look wonky.Try
add_filter( 'show_admin_bar', '__return_false', 99 );
I’ve also put a high priority on it to make sure it gets done ( a priority of 99 ).
Not saying this is the problem because I have very limited PHP knowledge but maybe that’s where echo bp_core_fetch_avatar( array(… is getting it’s Avatar from.
I can’t seem to duplicate the problem. It actually works for me.
Can you try using Twenty Thirteen? If that works then that shows something has been introduced (perhaps in your theme or maybe a plugin) which is conflicting with the function.
all I can think of is are you defining a custom avatar size in bp-custom?
@macpresss could there be some CSS in your theme that is resizing the avatar image?
Also, make sure to change
'height' => 15
to'height' => 32
as well.Try changing type to full. That said, I wouldn’t advise modifying core files.
Try posting your requirements in the BuddyPress Jobs Forum
@synaptic not a stupid question – always a good idea to improve performance. That said, removing comments isn’t where you should start.
1. Try minifying your scripts that haven’t already been minified.
2. Run your site through a tool such as tools.pingdom.com to identify all of the unnecessary resources your page is using – and remove them where appropriate
3. Deactivate unused plugins and so on…Some more ideas:
a) Lazy loading of images on long pages
b) Defer loading of javascriptSo many ways to improve performance – cutting back on comments, though, isn’t a way I’d recommend.
@mfmsw2youth Thanks for letting me know.
I hadn’t tested the code. Please try this and let me know how you get on:
function custom_activity_text_change_avatar( $entry, $user_id ) { $gender = bp_get_profile_field_data( 'field=Gender&user_id=' . $user_id ); $userlink = bp_core_get_userlink( $user_id ); if ( $gender == 'Male' ) { $entry = sprintf( __( '%s changed his profile picture', 'buddypress' ), $userlink ); } else if ( $gender == 'Female' ) { $entry = sprintf( __( '%s changed her profile picture', 'buddypress' ), $userlink ); } else { // the user hasn't told us if they are male or female so do nothing } return $entry; } add_filter( 'bp_xprofile_new_avatar_action', 'custom_activity_text_change_avatar', 10, 2 );
@bonaish try using Theme Check to test your chosen theme against the latest WP good practice:
https://wordpress.org/plugins/theme-check/
Then if you see lots of red flags then you can report them to the theme author. They’ll probably appreciate it as they can iron out any bugs they don’t already know about.
@matt-mcfarland glad to see you got this resolved!
You will need the php tags only if your functions.php file doesn’t already have them.
Oops return $entry should end with a semi colon eg
return $entry;
Try adding this to your theme’s functions.php file:
function custom_activity_text_change_avatar( $entry, $user_id ) { $gender = bp_get_profile_field_data( 'field=Gender&user_id=' . $user_id ); if ( $gender == 'Male' ) { $entry = sprintf( __( '%s changed his profile picture', 'buddypress' ), $userlink ); } else if ( $gender == 'Female' ) { $entry = sprintf( __( '%s changed her profile picture', 'buddypress' ), $userlink ); } else { // the user hasn't told us if they are male or female so do nothing } return $entry } add_filter( 'bp_xprofile_new_avatar_action', 'custom_activity_text_change_avatar', 10, 2 );
Notes:
1. Your profile field should be called Gender and it should be a radio button. Options should be Male or Female
Hi @mfmsw2youth
Can you paste the exact text here that you’d like to change. Eg the text that is coming up in your activity stream.
Hi @darrenmeehan looks good and works very well. I like that you can change the wording easily via the back end so if you’re not happy with ‘like’ then you could use ‘star’ or ‘favourite’.
Thanks!
@sundev you would need to capture each member’s gender using a profile field. A radio button would do it.
Then once you have that information you could do a simple check when filtering the text.
e.g
if ( is male ) { // this must be a male so filter the text to say 'his' } else { // this must be a woman so filter the text to say 'her' }
Filtering the text is the second step. If you let me know *exactly* the text you want to change, i’ll try to find where it is in the BP core code and see if a filter is available.
Hi @mfmsw2youth,
What is the exact text you’d like to change?
Hi @sundev
No, it wouldn’t change. You would need to filter the text accordingly depending on the gender they specify in their gender profile field.
@626design the best way to pinpoint the problem is remove all customisations you’ve made. Start with a theme such as Twenty Thirteen with no plugins activated. Then activate your plugins one by one. Then introduce your custom functions one by one. Test each time you make a change. It is a long winded process but when customising your site that is the only way to fix the problem. There’s no easier way I’ve come across.
How will you determine if the member is male or female?
Have you tried BuddyPress Usernames Only? https://wordpress.org/plugins/buddypress-usernames-only/
What was the function you added? Perhaps there is a problem with that
Site tracking – if you go to your WP admin area, look under BuddyPress where you can enable and disable components. You’ll see that you can enable site tracking. You’ll need to have this option checked to get notifications.
EDIT: Just re-read your question. You should get an email and core notification. Have you enabled ‘site-tracking’ in WP admin?