Jump to content

it's in a simple if


onedge2019

Recommended Posts

I am working on a project that is trying to “mesh” a couple scripts to make the overall project function as follows:
the avatar pulled from a social media login to go from blurry to clear once they complete their profile. The 1st script is what sets up the conditions. the 2nd script is I believe what shows at what % the member has completed their profile as well as if it is complete…

I need the new script to say if $user_id(whatever the function is) = 100% then show “large avatar” as in the script.

need some ideas on how this should read and if this is the right file I need to be looking for (is a plugin script for WordPress) or is there a more specific place I should be looking.

Thanks in advance.

Script 1

/**

  • Change avatar quality
    */
    function heateor_ss_custom_social_avatar( $avatar, $avuser, $size, $default, $alt = ‘’ ) {
    global $theChampLoginOptions;
    if ( isset( $theChampLoginOptions[‘enable’] ) && isset( $theChampLoginOptions[‘avatar’] ) ) {
    // I need a 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;

Script 2

<?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'
 
Link to comment
Share on other sites

is that expecting too much? I'll look past the snide comment, being a new poster to a forum and requesting assistance in "your home" and simply assume you did not understand my question; nor care to by insinuating I did not phrase my question properly?!

Let me make another attempt, my apologies for either expecting to much, or being hostile in re to my initial question.

context: I am new to php. There are a couple of pre existing (plug in) files in WordPress I am trying to modify so that the outcome is favorable to my project. The 1st code snippet (condensed to 2 lines) is:

if ( 1 ) {  **// condition for best quality**
 	$avatarType = 'thechamp_large_avatar';

 

Question(s):  I need to know the syntax as well as what condition to look for in the other .php files to add to the script

the 2nd script was the file I am assuming the condition I need is in. More closely here...(condensed to 13 lines)

/
 * 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 
 */
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  
    );

 

the rest of the script is in the above posts.

Thank you for any assistance

Link to comment
Share on other sites

Hi onedge2019, welcome. Please don't let the actions of a couple people sway your opinion of us as a whole.

I think I understand what you're trying to get out of this (blurring incomplete profiles) but I'm not sure what you still need to do to get there.

For example, according to some of the code you posted, it seems you can get the profile percentage value from

get_user_meta( $user_id, '_progress_bar_percent_level', true );

If that value is anything other than 100 then you would blur the image.

For the step of actually blurring it, if you're not sure how to do that then I would recommend CSS: use the percentage to apply a class to the profile image (or profile div or something that can be inherited by the actual <img>) and add CSS to apply a blurring effect in your stylesheet.

Link to comment
Share on other sites

ah no that actually makes sense, and thank you for your reply. As a side note I dont take the other comments to heart and actually half expected a few "quick replies" to be 'I'm not reading all of that' responses. But none the less made me re focus and ask a more precise question. Thanks again 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.