<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [2025] trunk: Fixing registration and avatar bugs with old 1.
 0 themes in 1.1.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2025</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-10-02 22:07:58 +0000 (Fri, 02 Oct 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixing registration and avatar bugs with old 1.0 themes in 1.1.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreactivationphp">trunk/bp-core/bp-core-activation.php</a></li>
<li><a href="#trunkbpcorebpcoreavatarsphp">trunk/bp-core/bp-core-avatars.php</a></li>
<li><a href="#trunkbpcorebpcorecssjsphp">trunk/bp-core/bp-core-cssjs.php</a></li>
<li><a href="#trunkbpcoredeprecatedbpcoredeprecatedphp">trunk/bp-core/deprecated/bp-core-deprecated.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
<li><a href="#trunkbpxprofilebpxprofileclassesphp">trunk/bp-xprofile/bp-xprofile-classes.php</a></li>
<li><a href="#trunkbpxprofiledeprecatedbpxprofiledeprecatedphp">trunk/bp-xprofile/deprecated/bp-xprofile-deprecated.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreactivationphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-activation.php (2024 => 2025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-activation.php        2009-10-01 14:11:10 UTC (rev 2024)
+++ trunk/bp-core/bp-core-activation.php        2009-10-02 22:07:58 UTC (rev 2025)
</span><span class="lines">@@ -6,6 +6,10 @@
</span><span class="cx">         if ( BP_ACTIVATION_SLUG != $bp-&gt;current_component )
</span><span class="cx">                 return false;
</span><span class="cx">                 
</span><ins>+        /* If we are using a BuddyPress 1.0 theme ignore this. */
+        if ( file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
+                return false;
+                
</ins><span class="cx">         /* Check if an activation key has been passed */
</span><span class="cx">         if ( isset( $_GET['key'] ) ) {
</span><span class="cx">                 
</span><span class="lines">@@ -67,7 +71,10 @@
</span><span class="cx">                 $bp-&gt;activation_complete = true;
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        bp_core_load_template( 'registration/activate' );
</del><ins>+        if ( '' != locate_template( array( 'registration/activate' ), false ) )
+                bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) );                
+        else
+                bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) );                
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'wp', 'bp_core_screen_activation', 3 );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpcorebpcoreavatarsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-avatars.php (2024 => 2025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-avatars.php        2009-10-01 14:11:10 UTC (rev 2024)
+++ trunk/bp-core/bp-core-avatars.php        2009-10-02 22:07:58 UTC (rev 2025)
</span><span class="lines">@@ -282,7 +282,7 @@
</span><span class="cx"> 
</span><span class="cx">         $r = wp_parse_args( $args, $defaults );
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ( !$original_file )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="lines">@@ -317,7 +317,7 @@
</span><span class="cx">         /* Crop the image */
</span><span class="cx">         $full_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
</span><span class="cx">         $thumb_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename );
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Remove the original */
</span><span class="cx">         @unlink( WP_CONTENT_DIR . $original_file );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpcorebpcorecssjsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-cssjs.php (2024 => 2025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-cssjs.php        2009-10-01 14:11:10 UTC (rev 2024)
+++ trunk/bp-core/bp-core-cssjs.php        2009-10-02 22:07:58 UTC (rev 2025)
</span><span class="lines">@@ -122,8 +122,10 @@
</span><span class="cx">                                 var ry = &lt;?php echo (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ?&gt; / coords.h;
</span><span class="cx"> 
</span><span class="cx">                                 jQuery('#avatar-crop-preview').css({
</span><ins>+                                &lt;?php if ( $image ) : ?&gt;
</ins><span class="cx">                                         width: Math.round(rx * &lt;?php echo $image[0] ?&gt;) + 'px',
</span><span class="cx">                                         height: Math.round(ry * &lt;?php echo $image[1] ?&gt;) + 'px',
</span><ins>+                                &lt;?php endif; ?&gt;
</ins><span class="cx">                                         marginLeft: '-' + Math.round(rx * coords.x) + 'px',
</span><span class="cx">                                         marginTop: '-' + Math.round(ry * coords.y) + 'px'
</span><span class="cx">                                 });
</span></span></pre></div>
<a id="trunkbpcoredeprecatedbpcoredeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/deprecated/bp-core-deprecated.php (2024 => 2025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/deprecated/bp-core-deprecated.php        2009-10-01 14:11:10 UTC (rev 2024)
+++ trunk/bp-core/deprecated/bp-core-deprecated.php        2009-10-02 22:07:58 UTC (rev 2025)
</span><span class="lines">@@ -711,7 +711,38 @@
</span><span class="cx">         &lt;/form&gt; &lt;?php
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function bp_core_handle_avatar_upload($file) {
+        global $wp_upload_error;
+        
+        require_once( ABSPATH . '/wp-admin/includes/file.php' );
+        
+        // Change the upload file location to /avatars/user_id
+        add_filter( 'upload_dir', 'xprofile_avatar_upload_dir' );
</ins><span class="cx"> 
</span><ins>+        $res = wp_handle_upload( $file['file'], array('action'=&gt;'slick_avatars') );
+
+        if ( !in_array('error', array_keys($res) ) ) {
+                return $res['file'];
+        } else {
+                $wp_upload_error = $res['error'];
+                return false;
+        }
+}
+
+function bp_core_resize_avatar( $file, $size = false ) {
+        require_once( ABSPATH . '/wp-admin/includes/image.php' );
+
+        if ( !$size )
+                $size = CORE_CROPPING_CANVAS_MAX;
+
+        $canvas = wp_create_thumbnail( $file, $size );
+
+        if ( $canvas-&gt;errors )
+                return false;
+
+        return $canvas = str_replace( '//', '/', $canvas );
+}
+
</ins><span class="cx"> /*** END OLD AVATAR CROPPING SUPPORT **************************/
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (2024 => 2025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2009-10-01 14:11:10 UTC (rev 2024)
+++ trunk/bp-groups.php        2009-10-02 22:07:58 UTC (rev 2025)
</span><span class="lines">@@ -568,8 +568,7 @@
</span><span class="cx">                                 bp_core_add_message( __( 'The group avatar was uploaded successfully!', 'buddypress' ) );
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
-        //var_dump($_COOKIE);
</del><ins>+
</ins><span class="cx">          bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpxprofilebpxprofileclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-classes.php (2024 => 2025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-classes.php        2009-10-01 14:11:10 UTC (rev 2024)
+++ trunk/bp-xprofile/bp-xprofile-classes.php        2009-10-02 22:07:58 UTC (rev 2025)
</span><span class="lines">@@ -621,23 +621,6 @@
</span><span class="cx">                         return true;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
-        /* Deprecated - Signup fields are now in the template */
-        function get_signup_fields() {
-                global $wpdb, $bp;
-                
-                $sql = $wpdb-&gt;prepare( &quot;SELECT f.id FROM {$bp-&gt;profile-&gt;table_name_fields} AS f, {$bp-&gt;profile-&gt;table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0        AND g.id = f.group_id ORDER BY f.id&quot;, get_site_option('bp-xprofile-base-group-name') );
-
-                if ( !$temp_fields = $wpdb-&gt;get_results($sql) )
-                        return false;
-                
-                for ( $i = 0; $i &lt; count($temp_fields); $i++ ) {
-                        $fields[] = new BP_XProfile_Field( $temp_fields[$i]-&gt;id, null, false );
-                }
-                
-                return $fields;
-        }
-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpxprofiledeprecatedbpxprofiledeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/deprecated/bp-xprofile-deprecated.php (2024 => 2025)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/deprecated/bp-xprofile-deprecated.php        2009-10-01 14:11:10 UTC (rev 2024)
+++ trunk/bp-xprofile/deprecated/bp-xprofile-deprecated.php        2009-10-02 22:07:58 UTC (rev 2025)
</span><span class="lines">@@ -405,7 +405,24 @@
</span><span class="cx">                 
</span><span class="cx">                 return $html;
</span><span class="cx">         }
</span><ins>+        
+        /* Deprecated - Signup fields are now in the template */
+        function get_signup_fields() {
+                global $wpdb, $bp;
+                
+                $sql = $wpdb-&gt;prepare( &quot;SELECT f.id FROM {$bp-&gt;profile-&gt;table_name_fields} AS f, {$bp-&gt;profile-&gt;table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0        AND g.id = f.group_id ORDER BY f.id&quot;, get_site_option('bp-xprofile-base-group-name') );
</ins><span class="cx"> 
</span><ins>+                if ( !$temp_fields = $wpdb-&gt;get_results($sql) )
+                        return false;
+                
+                for ( $i = 0; $i &lt; count($temp_fields); $i++ ) {
+                        $fields[] = new BP_XProfile_Field_Deprecated( $temp_fields[$i]-&gt;id, null, false );
+                }
+                
+                return $fields;
+        }
+
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /*** DEPRECATED SIGNUP FUNCTIONS *******/
</span><span class="lines">@@ -424,7 +441,7 @@
</span><span class="cx">         global $bp_xprofile_callback, $avatar_error, $avatar_error_msg;
</span><span class="cx"> 
</span><span class="cx">         /* Fetch the fields needed for the signup form */
</span><del>-        $fields = BP_XProfile_Field::get_signup_fields();
</del><ins>+        $fields = BP_XProfile_Field_Deprecated::get_signup_fields();
</ins><span class="cx"> 
</span><span class="cx">         if ( $fields ) {
</span><span class="cx">         ?&gt;
</span><span class="lines">@@ -536,7 +553,7 @@
</span><span class="cx">         $prev_field_id = -1;
</span><span class="cx">         
</span><span class="cx">         // Validate all sign up fields
</span><del>-        $fields = BP_XProfile_Field::get_signup_fields();
</del><ins>+        $fields = BP_XProfile_Field_Deprecated::get_signup_fields();
</ins><span class="cx"> 
</span><span class="cx">         if ( $fields ) {
</span><span class="cx">                 foreach ( $fields as $field ) {
</span><span class="lines">@@ -618,7 +635,8 @@
</span><span class="cx">                         // &quot;Handle&quot; upload into temporary location
</span><span class="cx">                         if ( $checked_upload &amp;&amp; $checked_size &amp;&amp; $checked_type &amp;&amp; !$original = bp_core_handle_avatar_upload($_FILES) ) {
</span><span class="cx">                                 $bp_signup_avatar_has_errors = true;
</span><del>-                                $avatar_error_msg = sprintf( __('Upload Failed! Error was: %s', 'buddypress'), $wp_upload_error );                                                
</del><ins>+                                $avatar_error_msg = sprintf( __('Upload Failed! Error was: %s', 'buddypress'), $wp_upload_error );        
+                                die;                                        
</ins><span class="cx">                         }
</span><span class="cx">         
</span><span class="cx">                         if ( $checked_upload &amp;&amp; $checked_size &amp;&amp; $checked_type &amp;&amp; $original &amp;&amp; !$canvas = bp_core_resize_avatar($original) )
</span><span class="lines">@@ -638,11 +656,18 @@
</span><span class="cx">                 $bp_user_signup_meta['avatar_image_resized'] = $canvas;
</span><span class="cx">                 $bp_user_signup_meta['avatar_image_original'] = $original;
</span><span class="cx">                 
</span><del>-                setcookie( 'bp_xprofile_meta', serialize($bp_user_signup_meta), time()+60*60*24, COOKIEPATH );
</del><ins>+                $bp_user_signup_meta = serialize( $bp_user_signup_meta );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> add_action( 'init', 'xprofile_load_signup_meta' );
</span><span class="cx"> 
</span><ins>+function xprofile_render_user_signup_meta() {
+        global $bp_user_signup_meta;
+        
+        echo '&lt;input type=&quot;hidden&quot; name=&quot;bp_xprofile_meta&quot; id=&quot;bp_xprofile_meta&quot; value=&quot;' . attribute_escape( $bp_user_signup_meta ) . '&quot; /&gt;';
+}
+add_action( 'signup_blogform', 'xprofile_render_user_signup_meta' );
+
</ins><span class="cx"> function xprofile_load_blog_signup_meta() {
</span><span class="cx">         global $bp_blog_signup_meta;
</span><span class="cx">         
</span><span class="lines">@@ -655,8 +680,8 @@
</span><span class="cx">                 'blog_title' =&gt; $_POST['blog_title']
</span><span class="cx">         );
</span><span class="cx">         
</span><del>-        $bp_meta = unserialize( stripslashes( $_COOKIE['bp_xprofile_meta'] ) );
-        $bp_blog_signup_meta = array_merge( $bp_meta, $blog_meta );
</del><ins>+        $bp_meta = unserialize( stripslashes( $_POST['bp_xprofile_meta'] ) );
+        $bp_blog_signup_meta = array_merge( (array)$bp_meta, (array)$blog_meta );
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'init', 'xprofile_load_blog_signup_meta' );
</span><span class="cx"> 
</span><span class="lines">@@ -670,7 +695,6 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wpmu_activate_blog', 'xprofile_on_activate_blog', 1, 5 );
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> function xprofile_on_activate_user( $user_id, $password, $meta ) {        
</span><span class="cx">         xprofile_extract_signup_meta( $user_id, $meta );
</span><span class="cx">         
</span><span class="lines">@@ -679,7 +703,7 @@
</span><span class="cx">         else 
</span><span class="cx">                 xprofile_handle_signup_avatar( $user_id, $meta );
</span><span class="cx"> }
</span><del>-add_action( 'wpmu_activate_user', 'xprofile_on_activate_user', 1, 3 );
</del><ins>+add_action( 'wpmu_activate_user', 'xprofile_on_activate_user', 1, 5 );
</ins><span class="cx"> 
</span><span class="cx"> function xprofile_extract_signup_meta( $user_id, $meta ) {
</span><span class="cx">         // Extract signup meta fields to fill out profile
</span><span class="lines">@@ -705,12 +729,16 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function xprofile_handle_signup_avatar( $user_id, $meta ) {
</span><ins>+        global $bp;
+        
+        $meta = maybe_unserialize( $meta );
+        
</ins><span class="cx">         $resized = $meta['avatar_image_resized'];
</span><span class="cx">         $original = $meta['avatar_image_original'];        
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ( !empty($resized) &amp;&amp; !empty($original) ) {
</span><span class="cx">                 // Create and set up the upload dir first.
</span><del>-                $upload_dir = bp_core_avatar_upload_dir( false, $user_id );
</del><ins>+                $upload_dir = xprofile_avatar_upload_dir( false, $user_id );
</ins><span class="cx">                 
</span><span class="cx">                 $resized_strip_path = explode( '/', $resized );
</span><span class="cx">                 $original_strip_path = explode( '/', $original );
</span><span class="lines">@@ -729,38 +757,66 @@
</span><span class="cx"> 
</span><span class="cx">                 $resized = $resized_new;
</span><span class="cx">                 $original = $original_new;
</span><del>-        
-                // Render the cropper UI
-                $action = bp_activation_page( false ) . '?key=' . $_GET['key'] . '&amp;amp;cropped=true';
-                bp_core_render_avatar_cropper($original, $resized, $action, $user_id);
</del><ins>+
+                $bp-&gt;avatar_admin-&gt;image = new stdClass;
+                $bp-&gt;avatar_admin-&gt;image-&gt;dir = $resized;
+                
+                /* Set the url value for the image */
+                $bp-&gt;avatar_admin-&gt;image-&gt;url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $bp-&gt;avatar_admin-&gt;image-&gt;dir );
+
+                ?&gt;
+                &lt;form action=&quot;&lt;?php echo $bp-&gt;root_domain . '/' . BP_ACTIVATION_SLUG ?&gt;&quot; method=&quot;post&quot;&gt;
+                        &lt;h3&gt;&lt;?php _e( 'Crop Your New Avatar', 'buddypress' ) ?&gt;&lt;/h3&gt;
+
+                        &lt;img src=&quot;&lt;?php echo attribute_escape( $bp-&gt;avatar_admin-&gt;image-&gt;url ) ?&gt;&quot; id=&quot;avatar-to-crop&quot; class=&quot;avatar&quot; alt=&quot;&lt;?php _e( 'Avatar to crop', 'buddypress' ) ?&gt;&quot; /&gt;
+
+                        &lt;input type=&quot;submit&quot; name=&quot;avatar-crop-submit&quot; id=&quot;avatar-crop-submit&quot; value=&quot;&lt;?php _e( 'Crop Image', 'buddypress' ) ?&gt;&quot; /&gt;
+
+                        &lt;input type=&quot;hidden&quot; name=&quot;image_src&quot; id=&quot;image_src&quot; value=&quot;&lt;?php echo attribute_escape( $bp-&gt;avatar_admin-&gt;image-&gt;dir ) ?&gt;&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; id=&quot;x&quot; name=&quot;x&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; id=&quot;y&quot; name=&quot;y&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; id=&quot;w&quot; name=&quot;w&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; id=&quot;h&quot; name=&quot;h&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; id=&quot;cropped&quot; name=&quot;cropped&quot; /&gt;
+                        &lt;input type=&quot;hidden&quot; id=&quot;key&quot; name=&quot;key&quot; value=&quot;&lt;?php echo attribute_escape( $_GET['key'] ) ?&gt;&quot;/&gt;
+
+                        &lt;?php wp_nonce_field( 'bp_avatar_cropstore' ); ?&gt;
+                &lt;/form&gt;&lt;?php
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function xprofile_deprecated_add_cropper_js() {        
+        global $bp;
+        
+        /* If we are using a BuddyPress 1.1+ theme ignore this. */
+        if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
+                return false;
+        
+        if ( $bp-&gt;current_component == BP_ACTIVATION_SLUG )
+                add_action( 'wp', 'bp_core_add_jquery_cropper' );
+}
+add_action( 'init', 'xprofile_deprecated_add_cropper_js' );
+
</ins><span class="cx"> function xprofile_catch_activate_crop() {
</span><del>-        if ( isset( $_GET['cropped'] ) ) {
</del><ins>+        if ( isset( $_POST['cropped'] ) ) {
+
</ins><span class="cx">                 // The user has cropped their avatar after activating account
</span><del>-                
</del><ins>+
</ins><span class="cx">                 // Confirm that the nonce is valid
</span><del>-                if ( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'slick_avatars' ) )
-                        bp_core_redirect( get_option('home') );
-                
-                $user_id = xprofile_get_user_by_key($_GET['key']);
</del><ins>+                check_admin_referer( 'bp_avatar_cropstore' );
</ins><span class="cx"> 
</span><del>-                if ( $user_id &amp;&amp; isset( $_POST['orig'] ) &amp;&amp; isset( $_POST['canvas'] ) ) {
-                        bp_core_check_crop( $_POST['orig'], $_POST['canvas'] );
-                        $result = bp_core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'] );
-                        bp_core_avatar_save( $result, $user_id );
-                }
-                
</del><ins>+                $user_id = xprofile_get_user_by_key( $_POST['key'] );
+
+                bp_core_avatar_handle_crop( array( 'item_id' =&gt; $user_id, 'original_file' =&gt; str_replace( WP_CONTENT_DIR, '', $_POST['image_src'] ), 'crop_x' =&gt; $_POST['x'], 'crop_y' =&gt; $_POST['y'], 'crop_w' =&gt; $_POST['w'], 'crop_h' =&gt; $_POST['h'] ) );
+
</ins><span class="cx">                 $ud = get_userdata($user_id);
</span><span class="cx">                 $url = site_url( BP_MEMBERS_SLUG . '/' . $ud-&gt;user_login );
</span><del>-                
</del><ins>+
</ins><span class="cx">                 bp_core_redirect( $url );
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> add_action( 'activate_header', 'xprofile_catch_activate_crop' );
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> function xprofile_get_user_by_key($key) {
</span><span class="cx">         global $wpdb;
</span><span class="cx">         
</span></span></pre>
</div>
</div>

</body>
</html>