-
Author
-
June 21, 2015 at 04:44 #64126LauraModerator
Hello, this will allow you to have a Default avatar for Female and one for Male, for now works only if you have 2 Genders in I am a field. Please Follow these instructions in order to customize the code.
Code:
COPY CODEadd_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' ); function myavatar_add_default_avatar( $url ) { global $bp; $gender = xprofile_get_field_data('I am a', bp_get_member_user_id()); if ($gender == "Male") { return $img_url = SECU.'MALE AVATAR URL OF IMAGE'; } else { return $img_url = SECU.'FEMALE AVATAR URL OF IMAGE'; } } add_filter( 'bp_core_mysteryman_src', 'myavatar_add_default_avatar' ); add_filter( 'bp_core_default_avatar_user', 'myavatar_add_default_avatar' );
How to Customize the code
As you can see, the code its fetching the field I am a, so maybe you have translated this field, so it wont work.
Just edit “I am a” With the Field Name of Gender Selection.Also, change Man for your Gender / Options. Only 2 Are possible for now.
If you prefer not to use this for Gender, and prefer maybe for Students, Teachers or any other topic, just change the names and the field and it will work.
Where to change the field:
IN ->COPY CODE$gender = xprofile_get_field_data('I am a', bp_get_member_user_id());
Change ONLY I am a for the name of your Field
Where to change the Gender / Values:
IN ->COPY CODEif ($gender == "Male") { return $img_url = SECU.'MALE AVATAR URL OF IMAGE'; } else { return $img_url = SECU.'FEMALE AVATAR URL OF IMAGE'; }
Change Male for ONE of the two Options, automatically the other option will get the SECOND image
Make Sure to add the url of your images where “MALE AVATAR URL OF IMAGE” and “FEMALE AVATAR URL OF IMAGE” appears.
Laura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy聽to help you 馃檪
July 13, 2015 at 14:53 #68019adamdale1ParticipantHi Laura,
Was very interested in the above, reference default avatar for Female/Male. So experimented with it! Have a few questions?1. Where is the code supposed to be inserted? Function.php or bp_function.php etc. ?
2. I keep getting a parse error on the 3rd line of code!
function myavatar_add_default_avatar( $url ) {So, any information on the above would be a great help. Thank you.
July 20, 2015 at 04:04 #69013LauraModeratorHello, sorry, didnt see the reply. The code needs to be inserted in functions.php
Please make sure you have the urls changedHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy聽to help you 馃檪
November 9, 2016 at 03:49 #143462RoaderParticipantLaura, podr铆as tener la amabilidad de explicarme d贸nde coloco el c贸digo php? O d贸nde debo modificar? M谩s detalles plis!
November 10, 2016 at 07:27 #143686LauraModeratorHola, todo esta muy bien explicado en el post 馃檪 Debes colocarlo en functions.php del child theme
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy聽to help you 馃檪
December 6, 2016 at 03:41 #146170RoaderParticipantHola Laura. Quiero aplicar este tutorial, pero no quiero cambiar ‘I am a’ por ‘Gender’.
Quiero mantener las opciones: ‘I am a’ => ‘Man’ , ‘Woman’. Entonces, c贸mo puedo usar este c贸digo para cambiar la imagen si un usuario es Hombre o Mujer?December 7, 2016 at 03:39 #146281LauraModeratorHola, no tienes que cambiar nada por genero, funciona con cualquier tipo de nombre. Si lo dejas tal y como esta funciona, solo que tendrias que cambiarlo a espa帽ol
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy聽to help you 馃檪
-
AuthorPosts
You must be logged in to reply to this topic.