• Resolved underpressure2019

    (@underpressure2019)


    In the setting it allows the admin to choose an avatar quality of average (poor) or good. How would I go about setting it so members of a certain group (in Buddy Press) can have a “better” quality image than users of a different group?

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Heateor Support

    (@heateor)

    Let me know what is the criteria of determining the avatar quality so that I can give you the custom code.

    Rajat

    Thread Starter underpressure2019

    (@underpressure2019)

    Sorry it has taken so long to get back I am working on a larger scale project working with this and remembered I still needed this information while looking up a problem I just encountered. So 1st Thank you for getting back, 2nd:

    To answer this initial question, I am throwing around a few ideas. I am working also with Gamipress (in fear of violating forum terms) So, the parameters are as follows:
    a member must spend x amount coins to unlock. How that is done doesnt matter. ie they could use the Gamipress points to buy a “widget” if a widget is seen on their profile it unlocks a clear pic or
    option 2; currently BP offers a “profile completion bar” and an award is given to those who compete it. If that award is seen then offer clear avatar.

    2nd Part
    I am now experiencing problems with the login feature. The buttons aren’t working properly (at all). They used to work fine now nothing. I had disabled the plugin and since enabling it it doesn’t seem to be working if I type in the short code on a “regular” or “added” (non registration) page. It will work however on the registration page. This problem has probably been asked and answered so a link to it will suffice. Thank you for your help with this project in advance.

    link-https://typhoonapps.com

    • This reply was modified 6 years, 1 month ago by underpressure2019. Reason: added link
    Thread Starter underpressure2019

    (@underpressure2019)

    2nd part resolved,
    I inadvertently switched the page template if anyone else comes across this and has a similar problem.

    Plugin Author Heateor Support

    (@heateor)

    You can add following code in functions.php file of your active theme to determine avatar quality:

    /**
     * Change avatar quality 
     */
    function heateor_ss_custom_social_avatar( $avatar, $avuser, $size, $default, $alt = '' ) {
    	global $theChampLoginOptions;
    	if ( isset( $theChampLoginOptions['enable'] ) && isset( $theChampLoginOptions['avatar'] ) ) {
                    // put your condition below
    		if ( 1 ) {  // condition for best quality
    			$avatarType = 'thechamp_large_avatar';
    		} else {    // condition for average quality
    			$avatarType = 'thechamp_avatar';
    		}
    		$userId = 0;
    		if ( is_numeric( $avuser ) ) {
    			if ( $avuser > 0 ) {
    				$userId = $avuser;
    			}
    		} elseif ( is_object( $avuser ) ) {
    			if ( property_exists( $avuser, 'user_id' ) AND is_numeric( $avuser->user_id ) ) {
    				$userId = $avuser->user_id;
    			}
    		} elseif ( is_email( $avuser ) ) {
    			$user = get_user_by( 'email', $avuser );
    			$userId = isset( $user->ID ) ? $user->ID : 0;
    		}
    
    		if ( $avatarType == 'thechamp_large_avatar' && get_user_meta( $userId, $avatarType, true ) == '' ) {
    			$avatarType = 'thechamp_avatar';
    		}
    		if ( ! empty( $userId ) && ( $userAvatar = get_user_meta( $userId, $avatarType, true ) ) !== false && strlen( trim( $userAvatar ) ) > 0 ) {
    			return '<img alt="' . esc_attr( $alt ) . '" src="' . $userAvatar . '" class="avatar avatar-' . $size . ' " height="' . $size . '" width="' . $size . '" style="height:'. $size .'px;width:'. $size .'px" />';
    		}
    	}
    	return $avatar;
    }
    add_filter( 'get_avatar', 'heateor_ss_custom_social_avatar', 100003, 5 );
    Thread Starter underpressure2019

    (@underpressure2019)

    thank you for getting me started in the right direction here.
    I have attached a the code of more of what I am looking for but for some reason I am not finding the function I need from the buddy profile progress bar functions.php to use as a condition. Here is what I have, any idea what I might be doing wrong?
    I have added the full code with my addition

    /**
     * Change avatar quality 
     */
    function heateor_ss_custom_social_avatar( $avatar, $avuser, $size, $default, $alt = '' ) {
    	global $theChampLoginOptions;
    	if ( isset( $theChampLoginOptions['enable'] ) && isset( $theChampLoginOptions['avatar'] ) ) {
                    // put your condition below
                    
    		if ( 1 ) { 
    		 if( isset( $user_percent ) && $user_percent != 0 )	// condition for best quality
    			$avatarType = 'thechamp_large_avatar';
    		} else {    // condition for average quality
    			$avatarType = 'thechamp_avatar';
    		}
    		$userId = 0;
    		if ( is_numeric( $avuser ) ) {
    			if ( $avuser > 0 ) {
    				$userId = $avuser;
    			}
    		} elseif ( is_object( $avuser ) ) {
    			if ( property_exists( $avuser, 'user_id' ) AND is_numeric( $avuser->user_id ) ) {
    				$userId = $avuser->user_id;
    			}
    		} elseif ( is_email( $avuser ) ) {
    			$user = get_user_by( 'email', $avuser );
    			$userId = isset( $user->ID ) ? $user->ID : 0;
    		}
    
    		if ( $avatarType == 'thechamp_large_avatar' && get_user_meta( $userId, $avatarType, true ) == '' ) {
    			$avatarType = 'thechamp_avatar';
    		}
    		if ( ! empty( $userId ) && ( $userAvatar = get_user_meta( $userId, $avatarType, true ) ) !== false && strlen( trim( $userAvatar ) ) > 0 ) {
    			return '<img alt="' . esc_attr( $alt ) . '" src="' . $userAvatar . '" class="avatar avatar-' . $size . ' " height="' . $size . '" width="' . $size . '" style="height:'. $size .'px;width:'. $size .'px" />';
    		}
    	}
    	return $avatar;
    }
    add_filter( 'get_avatar', 'heateor_ss_custom_social_avatar', 100003, 5 );
    Thread Starter underpressure2019

    (@underpressure2019)

    in addition I thought it might be helpful to add the functions code from the progress bar.

    <?php
    // Exit if accessed directly
    if ( !defined( 'ABSPATH' ) ) exit;
    
    /**
     * Returns plugin version
     * 
     * @uses bppp() plugin's main instance
     *
     * since 1.0
     */
    function bppp_get_plugin_version() {
    	return bppp()->version;
    }
    
    /**
     * Url to images dir
     *
     * @uses  bppp()
     * @return string the url
     *
     * since 1.0
     */
    function bppp_get_images_url() {
    	return bppp()->images_url;
    }
    
    /**
     * Register points filter
     *
     * The callback must either return bool (eg. TRUE, which equals 100%) or a percentage (eg. 50)
     * @param type	 $label
     * @param type	 $callback
     * @param type	 $points
     * @param type	 $args 
     * 
     * since 1.0
     */
    function bppp_register_progression_point( $label, $name, $callback, $points, $args = false ) {
    	
    	$point = array(
    		'label'		=> $label,		// label for this item aka 
    		'name'		=> $name,		// display name 
    		'callback'	=> $callback,	// name of the function used to retrieve the user's percents for this item
    		'points'	=> $points		// number of points this item potentially gives  
    	);
    
        if( $args )
            $point['args'] = $args;
    
        bppp()->query->points[] = apply_filters( 'bppp_register_progression_point_'. $label, $point );
    }
    
    /**
     * Get points total
     * 
     * @return int
     *
     * since 1.0
    */
    function bppp_get_total_points() {
    
        $total = 0;
    
        foreach( ( array ) bppp()->query->points as $item ) {
            $total+= $item['points'];
        }
    
        return $total;
    }
    
    /**
    * Builds a link to message composer on users list
    *
    * Display progression percent in Profile Status column
    * if no data is found, shows a send message button
    *
    * @since 1.0
    */
    function progress_bar_add_percent_column_content( $value, $column_name, $user_id ) {
    
    	if ( 'progress_profile' == $column_name ) {
    		if( !bp_is_active( 'messages') ) {
    			  $warning = __( 'BuddyPress Message Component must be activated.', 'buddy-progress-bar' );
    				return $warning;
    		  }
    
    		$user			= get_userdata( $user_id );
    		$user_percent	= get_user_meta( $user_id, '_progress_bar_percent_level', true );
    	  
    		if( bp_is_active( 'messages') ) {
    		  $link			= wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( $user_id ) );
    		}
    		$recipient		= '&nbsp;'. bp_core_get_username( $user_id );
    		$ico 			= '<span class="dashicons dashicons-email-alt"></span>';
    	  
    		$defaults = array(
    		  'id' => 'complete_profile_message-'.$user_id,
    		  'component' => 'messages',
    		  'must_be_logged_in' => true,
    		  'block_self' => true,  
    		  'wrapper_id' => 'complete-profile-message-'.$user_id,
    		  'wrapper_class' =>'complete-profile-message',
    		  'link_href' => $link,
    		  'link_title' => __( 'Send a message to', 'buddy-progress-bar' ) . $recipient,
    		  'link_text' => $ico,
    		  'link_class' => 'send-message',
    		);
    
    		if( isset( $user_percent ) && $user_percent != 0 ) {
    			  return sprintf( '%s %%', $user_percent );		
    		  } else { 
    			  $btn = bp_get_button( $defaults ); 
    			return apply_filters( 'progress_bar_get_send_private_message_button', $btn );
    		  }	
    	}
      
      return $value;
    }
    
    add_filter( 'manage_users_custom_column','progress_bar_add_percent_column_content', 10, 3 );
    
    /**
    * Add Welcome page menu
    *
    * @since 1.0
    */
    function bppp_about_screen_page() {
      add_dashboard_page(
        'About Progress Bar',
        'About Progress Bar',
        'read',
        'bppp-about',
        'bppp_about_screen'
      );
    }
    add_action('admin_menu', 'bppp_about_screen_page');
    
    /**
    * Remove welcome link from wp admin menu
    *
    * @since 1.0
    */
    function bppp_about_screen_remove_menu() {
        remove_submenu_page( 'index.php', 'bppp-about' );
    }
    add_action( 'admin_head', 'bppp_about_screen_remove_menu' );
    Plugin Author Heateor Support

    (@heateor)

    I can help you with the social avatar condition related to my plugin, as I posted the code above. You just need to put the conditions you want in the code. The help you are asking is out of the domain of the plugin.

    Thread Starter underpressure2019

    (@underpressure2019)

    understandable, thank you for your help and support.

    Plugin Author Heateor Support

    (@heateor)

    No problem.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Avatar quality’ is closed to new replies.