BuddyDev

Search

BP Force Profile Photo

  • Participant
    Level: Initiated
    Posts: 4
    Aaron Thomas on #6087

    Hello Buddydev users,

    I am interested in any suggestions someone might have for tweaking the BP Force Profile Photo plugin.

    By default, it’s an essential plugin for me to use, however, I believe it has room to grow as far as customization.

    What I’d like to change about it is the way it gives the illusion that the user has access to do things, that really he/she doesn’t have access to do. (Like menu items that display for logged in users only)

    I would also like to hide all the other BP profile options that the user sees when they get to this point. I assume that this particular idea might be impossible, because the user will absolutely need to have access to his profile options in order to upload the photo.

    I’m interested in seeing what others have done to make this wonderful plugin flow with their site. Please share!

    Thank you.

  • Keymaster
    (BuddyDev Team)
    Posts: 21467
    Brajesh Singh on #6094

    Hi Aaron,
    Welcome to BuddyDev forums.

    It is a good question and I believe we may go for this kind of thing. Here is what can be done.

    1. Add a class to body if the user has not uploaded a photo say we add ‘no-profile-photo’
    2. Then we can use css like this to hide all profile navigation links

    
    
    body.no-profile-photo .item-list-tabs {
    display:none;
    }
    
    

    There is no harm in hiding as the user is redirected to the change profile photo page.

    Hope that helps.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 4
    Aaron Thomas on #6111

    Thanks for your reply!

    I must admit, I am a beginner with PHP. I don’t know exactly how to complete step 1:

    (1. Add a class to body if the user has not uploaded a photo say we add ‘no-profile-photo’)

    If you get time, please give me more detailed instructions on how to do this part.

    The 2nd part sounds easy, I assume I would just add that CSS code to my theme’s stylesheet.

    As always, thanks for your time & for sharing this great plugin with us.

  • Keymaster
    (BuddyDev Team)
    Posts: 21467
    Brajesh Singh on #6114

    Hi Aaron,

    Please put the following code in your bp-custom.php

    
    /**
     * Add class 'no-profile-photo' to body if the user has not yet uploaded an vatar
     *
     * Works with BuddyPress Force Profile Photo Plugin
     *
     * @param $classes
     *
     * @return array
     */
    function buddydev_custom_add_profile_photo_class_to_body( $classes ) {
    
    	if ( ! is_user_logged_in() || ! class_exists( 'BD_Force_User_Avatar_Helper' ) ) {
    		return $classes;
    	}
    
    	if ( ! is_super_admin() && ! BD_Force_User_Avatar_Helper::get_instance()->has_uploaded_avatar( bp_loggedin_user_id() )  ) {
    		$classes[] = 'no-profile-photo';//the user has no profile photo
    	}
    
    	return $classes;
    }
    add_filter( 'bp_get_the_body_class', 'buddydev_custom_add_profile_photo_class_to_body' );
    

    It will add the appropriate class. You can use the css then.

    Hope that helps.

  • Participant
    Level: Initiated
    Posts: 4
    Aaron Thomas on #6729

    Brajesh,

    Thank you for trying to help me with this enhancement.

    I did not manage to get this to work. I inserted the php code into my bp-custom.php, and I inserted the css code into my theme’s style.css. With that being said, did I work with the right files?

    I get this message in the WP dashboard:

    hoto’ to body if the user has not yet uploaded an avatar * * Works with BuddyPress Force Profile Photo Plugin * * @param $classes * * @return array */ function buddydev_custom_add_profile_photo_class_to_body( $classes ) { if ( ! is_user_logged_in() || ! class_exists( ‘BD_Force_User_Avatar_Helper’ ) ) { return $classes; } if ( ! is_super_admin() && ! BD_Force_User_Avatar_Helper::get_instance()->has_uploaded_avatar( bp_loggedin_user_id() ) ) { $classes[] = ‘no-profile-photo’;//the user has no profile photo } return $classes; } add_filter( ‘bp_get_the_body_class’, ‘buddydev_custom_add_profile_photo_class_to_body’ );

  • Keymaster
    (BuddyDev Team)
    Posts: 21467
    Brajesh Singh on #6750

    Hi Aaron,
    Can you please post the complete content of your bp-custom.php? It seems you don’t have opening php tag?

    Please post the file on pastebin.com and link me here,

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 4
    Aaron Thomas on #6767

    Brajesh,

    My mistake, you were correct, my bp-custom.php was not valid, but I think I have fixed that file now, and it looks like this:

    <?php
    /**
     * Add class 'no-profile-photo' to body if the user has not yet uploaded an avatar
     *
     * Works with BuddyPress Force Profile Photo Plugin
     *
     * @param $classes
     *
     * @return array
     */
    function buddydev_custom_add_profile_photo_class_to_body( $classes ) {
    
    	if ( ! is_user_logged_in() || ! class_exists( 'BD_Force_User_Avatar_Helper' ) ) {
    		return $classes;
    	}
    
    	if ( ! is_super_admin() && ! BD_Force_User_Avatar_Helper::get_instance()->has_uploaded_avatar( bp_loggedin_user_id() )  ) {
    		$classes[] = 'no-profile-photo';//the user has no profile photo
    	}
    
    	return $classes;
    }
    add_filter( 'bp_get_the_body_class', 'buddydev_custom_add_profile_photo_class_to_body' );
    ?>

    — This is my fist time using bp-custom.php, and it’s only purpose, right now, is to accomplish this project with BP Force Profile Photo. I have placed this file in my plugins folder. —

    I have placed this css in my child theme’s style.css file:

    body.no-profile-photo .item-list-tabs {
    display:none;
    }

    But, the links still appear. Can you spot any mistakes?

    Thank you very much for your time.

  • Keymaster
    (BuddyDev Team)
    Posts: 21467
    Brajesh Singh on #6772

    Hi Aaron,
    Is there any chance that you are checking this while being logged in as site admin?

  • Participant
    Level: Initiated
    Posts: 4
    Aaron Thomas on #6824

    Definitely not.

You must be logged in to reply to this topic.

This topic is: not resolved