This topic has 17 replies, 6 voices, and was last updated 7 years by Laura.

  • Author
  • #63538
     Haven
    Participant

    I design the default avatars for man and woman.
    I hope when the website show default avatar , it can show default man avatar image and default woman avatar image according to the user profile.
    How can I do ?

    #63896
     Laura
    Moderator

    Hello, it can be done with custom code, try this in functions.php of child theme

    COPY CODE
    
    add_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' );
    

    Just add the url for female an male images and it should work.
    It works only if you have Male and Female and no more options in I am a field

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

    #64003
     Haven
    Participant

    I tried this code, excellent!, it work nice. now the users show default avatar according their gender.
    Thank u lots!

    #64124
     Laura
    Moderator

    Glad it worked!

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

    #72903
     jenny555
    Participant

    Hi, i try it, but it doesn’t work for me. I also have a problem with the display of women online and men online in homepage doesn’t work well, this may be related. Can you help me please?

    #73068
     Laura
    Moderator

    Hello, do you have your site in another language? If so, you need to change the shortcode in homepage, and change woman and man for your language words, also in the code above

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

    #73188
     jenny555
    Participant

    Hello Laura,
    yes i have the french language activated. I tried what you told me to do, but it doesn’t. Here is my functions file:

    COPY CODE
    <?php
    /**
     * @package WordPress
     * @subpackage Sweetdate
     * @author SeventhQueen <themesupport@seventhqueen.com>
     * @since Sweetdate 1.0
     */
    
    /**
     * Sweetdate Child Theme Functions
     * Add extra code or replace existing functions
    */ 
    
    //Avatar default
    add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
    	function myavatar_add_default_avatar( $url )
    	{
    		global $bp;
    		$gender = xprofile_get_field_data('Je suis', bp_get_member_user_id());
    		if ($gender == "Homme") {
    			return $img_url = SECU.'/wp-content/uploads/2015/08/avatarh.png';
    		}
    		else {
    			return $img_url = SECU.'/wp-content/uploads/2015/08/avatarf.png';
    		}
    	}
    	add_filter( 'bp_core_mysteryman_src', 'myavatar_add_default_avatar' );
    	add_filter( 'bp_core_default_avatar_user', 'myavatar_add_default_avatar' );
    	
    
    //manual total members
    	add_filter( 'bp_get_total_member_count', 'kleo_my_total_members' );
    function kleo_my_total_members($number) {
    	$number = str_replace(".","",$number);
    	return 1284;
    }
    //manual number online members
    add_filter( 'kleo_online_users_count', 'kleo_my_online_users', 10, 2);
    function kleo_my_online_users($number, $value) {
    	switch ($value) {
    		//ALL MEMBERS ONLINE
    		case FALSE:
    			return '195';
    			break;
    
    		case "Woman":
    			return $number+51;
    			break;
    		
    		case "Man":
    			return $number+134;
    			break;
    		
    		
    		default:
    			return $number;
    			break;
    	}
        
    }
    ?>

    what doesn’t work? Also I didn’t understand what I have to change in the homepage. Thanks

    #73431
     Laura
    Moderator

    Hello, have you tried using the full url path of the image? “http://mywebsite.com/…&#8221;

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

    #73496
     jenny555
    Participant

    Hello Laura, problem solved! it works!
    Here is the solution for members who have the same problem as me …
    We do need to change, “I am a” and “Man” in your language (case sensitive). Then, this blocking, it is the “SECU.” before url in the code. I deleted it and it works.
    Here are the correct code. But I have more questions then I’ll open another topic. In the meantime, thank you.

    COPY CODE
    //Avatar default
    add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
    	function myavatar_add_default_avatar( $url )
    	{
    		global $bp;
    		$gender = xprofile_get_field_data('Je suis', bp_get_member_user_id());
    		if ($gender == "Un Homme") {
    			return $img_url = '/wp-content/uploads/2015/08/avatarh.png';
    		}
    		else {
    			return $img_url ='/wp-content/uploads/2015/08/avatarf.png';
    		}
    	}
    	add_filter( 'bp_core_mysteryman_src', 'myavatar_add_default_avatar' );
    	add_filter( 'bp_core_default_avatar_user', 'myavatar_add_default_avatar' );
    #73831
     Laura
    Moderator

    Hello, glad you could do it!

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

    #129905
     love2playgames
    Participant

    Hi Laura,

    Ok, good news I also got this Male/Female going.

    The bad news is this default avatar function is taking over ALL the members that already has their own profile avatar previously…

    So it seems like it will work good ONLY for the NEW members that upload their profile image to replace this default avatar. OR wouldn’t over write with the registered avatar by email or facebook image.

    I end up have to take out this functions after all 🙁

    Can you help me how to fix this default function ONLY for the Mystry Man and NOT overwrite or avoid the existing member avatar?

    Please advise big time help. Thanks

    #130153
     Laura
    Moderator

    Hello, that is not available right now 🙁

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

    #149536
     boraboramedia
    Participant

    I got this code working to. Very nice!

    However, I was wondering if 1 change is possible. At this moment when somebody register they always get the Female placeholder. Also if it is a man. When the user saves their profile, the right placeholder is set.

    So my question is. Is it possible to use the custom unisex placeholder of SweetDate, but when the user saves their profile for the 1st time, the right placeholder will be loaded, of course only when they do not have uploaded a own picture.

    Thnx!

    #149694
     Laura
    Moderator

    Hello you could make them the same image so they look unisex

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

    #150044
     boraboramedia
    Participant

    But I would like to use 2 images, one for men profiles and one for female profiles. Like the above snippet does. It just loads the female placeholder by default, but I would like that the default SweetDate placeholder is loaded. And when somebody saves their profile the man/female placeholder is loaded. Hopefully you can help me with this…

    #150285
     Laura
    Moderator

    Hello, this would require more development so i suggest to hire a developer. As this snippet doesn’t have default images

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

    #151351
     mrchristophee
    Participant

    How can you use this code in Kleo, there is no ‘I am a’ Field?

    #151670
     Laura
    Moderator

    Hello, you can add it at Users > Profile fields

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    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 🙂

Viewing 18 posts - 1 through 18 (of 18 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?