bp_get_signup_avatar

Get the user avatar during signup.

Description

(string) bp_get_signup_avatar( (string) $args = '' ); 

Returns (string)

Parameters (1)

0. $args — Optional. (string) => ''
Array of optional arguments.

Options

array(

    /**
     * Height/weight in pixels. Default: value of bp_core_avatar_full_width().
     *
     * @type int
     */
    'size' => 0,

    /**
     * CSS class. Default: 'avatar'.
     *
     * @type string
     * @default ''
     */
    'class' => ''
);        


Usage

  1. if ( !function_exists( 'bp_get_signup_avatar' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-template.php'; 
  3.  
  4. // Array of optional arguments. 
  5. $args = array( 
  6. 'size' => 0, 
  7. 'class' => '' 
  8. ); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_get_signup_avatar($args); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-members/bp-members-template.php  
  1. function bp_get_signup_avatar( $args = '' ) { 
  2. $bp =buddypress); 
  3.  
  4. $defaults = array( 
  5. 'size' => bp_core_avatar_full_width(),  
  6. 'class' => 'avatar',  
  7. 'alt' => __( 'Your Profile Photo', buddypress ) 
  8. ); 
  9.  
  10. $r = wp_parse_args( $args, $defaults ); 
  11. extract( $r, EXTR_SKIP ); 
  12.  
  13. // Avatar DIR is found. 
  14. if ( $signup_avatar_dir = bp_get_signup_avatar_dir_value() ) { 
  15. $gravatar_img = bp_core_fetch_avatar( array( 
  16. 'item_id' => $signup_avatar_dir,  
  17. 'object' => 'signup',  
  18. 'avatar_dir' => 'avatars/signups',  
  19. 'type' => 'full',  
  20. 'width' => $size,  
  21. 'height' => $size,  
  22. 'alt' => $alt,  
  23. 'class' => $class 
  24. ) ); 
  25.  
  26. // No avatar DIR was found. 
  27. } else { 
  28.  
  29. // Set default gravatar type. 
  30. if ( empty( $bp->grav_default->user ) ) 
  31. $default_grav = 'wavatar'; 
  32. elseif ( 'mystery' == $bp->grav_default->user ) 
  33. $default_grav = $bp->plugin_url . 'bp-core/images/mystery-man.jpg'; 
  34. else 
  35. $default_grav = $bp->grav_default->user; 
  36.  
  37. /** 
  38. * Filters the base Gravatar url used for signup avatars when no avatar dir found. 
  39. * @since 1.0.2 
  40. * @param string $value Gravatar url to use. 
  41. */ 
  42. $gravatar_url = apply_filters( 'bp_gravatar_url', '//www.gravatar.com/avatar/' ); 
  43. $md5_lcase_email = md5( strtolower( bp_get_signup_email_value() ) ); 
  44. $gravatar_img = '<img src="' . $gravatar_url . $md5_lcase_email . '?d=' . $default_grav . '&s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />'; 
  45.  
  46. /** 
  47. * Filters the user avatar during signup. 
  48. * @since 1.1.0 
  49. * @param string $gravatar_img Avatar HTML image tag. 
  50. * @param array $args Array of parsed args for avatar query. 
  51. */ 
  52. return apply_filters( 'bp_get_signup_avatar', $gravatar_img, $args );