Filter 'edit_user_avatar' not working
-
Hello,
I have been trying to get this filter working for some time now. I am still not able to get through this. I also found a bug in the in the classWP_User_Avatar
functionwpua_action_show_user_profile
(line156
and158
)$has_wp_user_avatar = has_wp_user_avatar(@$user->ID); // Get WPUA attachment ID $wpua = get_user_meta(@$user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
If you var_dump
$wpua
, you get abool(false)
response. I thought this was because of@$user->ID
sinceglobal $current_user
was used, so I simply replaced@$user->ID
with$current_user
and the image which I attached from the dashboard profile page showed up.But the main issue still remains, the post is not getting updated if I select a new image from my custom profile page. Below is a video showing the process of adding a new image (This is before I made any changes to the plugin files) ..
VIDEO: https://goo.gl/Z04kEU
P.S: If you think its because of the password fields, if I have checked it with correct inputs ..CODES
Functions.php
/** * [my_avatar_filter] * Filter for WP User Avatar */ function my_avatar_filter() { // Remove from show_user_profile hook remove_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile')); remove_action('show_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts')); // Remove from edit_user_profile hook remove_action('edit_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile')); remove_action('edit_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts')); // Add to edit_user_avatar hook add_action('edit_user_avatar', array('wp_user_avatar', 'wpua_action_show_user_profile')); add_action('edit_user_avatar', array('wp_user_avatar', 'wpua_media_upload_scripts')); } // Loads only outside of administration panel if(!is_admin()) { add_action('init','my_avatar_filter'); } // Custom Wrapper for WP User Avatar remove_action('wpua_before_avatar', 'wpua_do_before_avatar'); remove_action('wpua_after_avatar', 'wpua_do_after_avatar'); function my_before_avatar() { echo '<div class="avatar" id="my-avatar">'; } add_action('wpua_before_avatar', 'my_before_avatar'); function my_after_avatar() { echo '</div>'; } add_action('wpua_after_avatar', 'my_after_avatar');
The Form:
<form id="wpua-edit-1" class="wpua-edit" action="" method="post" enctype="multipart/form-data"> <?php do_action('edit_user_avatar', $current_user->ID ); ?> <div class="personal-wrapper"> <div class="name-details"> <div class="form-group"> <label for="first-name"><?php _e('First Name', 'profile'); ?></label> <input class="form-control" name="first-name" type="text" id="first-name" value="<?php the_author_meta( 'first_name', $current_user->ID ); ?>" /> </div><!-- .form-username --> <div class="form-group middle-in"> <label for="middle-in"><?php _e('Middle in.', 'profile'); ?></label> <input class="form-control" name="middle-in" type="text" id="middle-in" value="<?php the_author_meta( '_middle_in', $current_user->ID ); ?>" /> </div><!-- .form-middle in. --> <div class="form-group"> <label for="last-name"><?php _e('Last Name', 'profile'); ?></label> <input class="form-control" name="last-name" type="text" id="last-name" value="<?php the_author_meta( 'last_name', $current_user->ID ); ?>" /> </div><!-- .form-username --> </div> <div class="email-wrap"> <div class="form-group"> <label for="email"><?php _e('E-mail *', 'profile'); ?></label> <input class="form-control" name="email" type="text" id="email" value="<?php the_author_meta( 'user_email', $current_user->ID ); ?>" /> </div><!-- .form-email --> </div> <div class="password-wrap"> <div class="form-group"> <label for="pass1"><?php _e('Password *', 'profile'); ?> </label> <input class="form-control" name="pass1" type="text" id="pass1" /> </div><!-- .form-password --> <div class="form-group"> <label for="pass2"><?php _e('Repeat Password *', 'profile'); ?></label> <input class="form-control" name="pass2" type="password" id="pass2" /> </div><!-- .form-password --> </div> <div class="phone-wrap"> <div class="form-group"> <label for="phno1"><?php _e('Primary Phone Number', 'profile'); ?> </label> <input class="form-control" name="phno1" type="text" id="phno1" value="<?php the_author_meta( '_primary_phone_number', $current_user->ID ); ?>" /> </div><!-- .Primary Phone Number --> <div class="form-group"> <label for="phno2"><?php _e('Secondary Phone Number', 'profile'); ?></label> <input class="form-control" name="phno2" type="text" id="phno2" value="<?php the_author_meta( '_secondary_phone_number', $current_user->ID ); ?>" /> </div><!-- .Secondary Phone Number --> </div> <div class="address-wrap"> <div class="form-group"> <label for="address"><?php _e('Address', 'profile'); ?></label> <input class="form-control" name="address" type="text" id="address" value="<?php the_author_meta( '_address', $current_user->ID ); ?>" /> </div><!-- .Address --> <div class="form-group"> <label for="city"><?php _e('City', 'profile'); ?></label> <input class="form-control" name="city" type="text" id="city" value="<?php the_author_meta( '_city', $current_user->ID ); ?>"/> </div><!-- .City --> <div class="form-group state"> <label for="state"><?php _e('State', 'profile'); ?></label> <input class="form-control" name="state" type="text" id="state" value="<?php the_author_meta( '_state', $current_user->ID ); ?>"/> </div><!-- .State --> <div class="form-group"> <label for="zipcode"><?php _e('Zip/Code', 'profile'); ?></label> <input class="form-control" name="zipcode" type="text" id="zipcode" value="<?php the_author_meta( '_zipcode', $current_user->ID ); ?>"/> </div><!-- .Zip/Code --> </div> <div class="baptism-wrap"> <div class="form-group"> <label for="baptized"><?php _e('Are you Baptized?', 'profile'); ?></label> <select name='baptized' class="form-control"> <?php if( get_user_meta($current_user->ID, '_baptized', true) == "yes" ) { echo "<option value=\"\">Select your option</option> <option value='yes' selected>Yes</option> <option value='no'>No</option>"; } elseif ( get_user_meta($current_user->ID, '_baptized', true) == "no") { echo "<option value=\"\">Select your option</option> <option value='yes' >Yes</option> <option value='no' selected>No</option>"; } else { echo "<option value=\"\" disabled selected>Select your option</option> <option value='yes' >Yes</option> <option value='no' selected>No</option>"; }?> </select> </div><!-- .Baptized --> <div class="form-group"> <label for="baptized-date"><?php _e('Date of Baptism', 'profile'); ?></label> <input class="form-control date-picker" name="baptized-date" type="text" id="baptized-date" value="<?php the_author_meta( '_baptized_date', $current_user->ID ); ?>"/> </div><!-- .Baptized Date --> </div> <div class="dob-wrap"> <div class="form-group gender"> <label for="gender"><?php _e('Gender', 'profile'); ?></label> <select name='gender' class="form-control"> <?php if( get_user_meta($current_user->ID, '_gender', true) == "male" ) { echo "<option value=\"\">Select your option</option> <option value='male' selected>Male</option> <option value='female'>Female</option>"; } elseif ( get_user_meta($current_user->ID, '_gender', true) == "female") { echo "<option value=\"\">Select your option</option> <option value='male'>Male</option> <option value='female' selected>Female</option>"; } else { echo "<option value=\"\" disabled selected>Select your option</option> <option value='male'>Male</option> <option value='female'>Female</option>"; }?> </select> </div><!-- .Gender --> <div class="form-group dob"> <label for="dob"><?php _e('DOB', 'profile'); ?></label> <input class="form-control" name="dob" type="text" id="dob" value="<?php the_author_meta( '_date_of_birth', $current_user->ID ); ?>"/> </div><!-- .DOB --> <div class="form-group contact-time"> <label for="contact-time"><?php _e('When is it best to contact you?', 'profile'); ?></label> <input class="form-control" name="contact-time" type="text" id="contact-time" value="<?php the_author_meta( '_best_contact_time', $current_user->ID ); ?>"/> </div><!-- .form-url --> </div> </div> <div class="family-wrapper"> <h3 class="my-account-title">FAMILY</h3> <div class="left-col"> <div class="form-group"> <label for="marital-status"><?php _e('Marital Status', 'profile'); ?></label> <input class="form-control" name="marital-status" type="text" id="marital-status" value="<?php the_author_meta( '_marital_status', $current_user->ID ); ?>"/> </div><!-- .marital status --> <div class="form-group"> <label for="spouse"><?php _e('Who\'s your Spouse', 'profile'); ?></label> <input class="form-control" name="spouse" type="text" id="spouse" value="<?php the_author_meta( '_who_is_your_spouse', $current_user->ID ); ?>"/> </div><!-- .spouse --> </div> <h2>or</h2> <div class="right-col"> <div class="name-details"> <div class="form-group"> <label for="form-spouse-first-name"><?php _e('Spouse First Name', 'profile'); ?></label> <input class="form-control" name="spouse-first-name" type="text" id="spouse-first-name" value="<?php the_author_meta( '_spouse_first_name', $current_user->ID ); ?>"/> </div><!-- .spouse first name --> <div class="form-group spouse-middle-in"> <label for="spouse-middle-in"><?php _e('Middle In.', 'profile'); ?></label> <input class="form-control" name="spouse-middle-in" type="text" id="spouse-middle-in" value="<?php the_author_meta( '_spouse_middle_in', $current_user->ID ); ?>"/> </div><!-- .spouse middle in --> <div class="form-group"> <label for="spouse-last-name"><?php _e('Last Name', 'profile'); ?></label> <input class="form-control" name="spouse-last-name" type="text" id="spouse-last-name" value="<?php the_author_meta( '_spouse_last_name', $current_user->ID ); ?>"/> </div><!-- .spouse last name --> </div> <div class="baptism-wrap"> <div class="form-group"> <label for="spouse-baptized-status"><?php _e('Is (s)he baptized?', 'profile'); ?></label> <select name='spouse-baptized-status' class="form-control"> <?php if( get_user_meta($current_user->ID, '_spouse_baptized_status', true) == "yes" ) { echo "<option value=\"\">Select your option</option> <option value='yes' selected>Yes</option> <option value='no'>No</option>"; } elseif ( get_user_meta($current_user->ID, '_spouse_baptized_status', true) == "no") { echo "<option value=\"\">Select your option</option> <option value='yes' >Yes</option> <option value='no' selected>No</option>"; } else { echo "<option value=\"\" disabled selected>Select your option</option> <option value='yes' >Yes</option> <option value='no' selected>No</option>"; }?> </select> </div><!-- .spouse baptized status --> <div class="form-group"> <label for="spouse-date-of-baptism"><?php _e('Date of Baptism', 'profile'); ?></label> <input class="form-control date-picker" name="spouse-date-of-baptism" type="text" id="spouse-date-of-baptism" value="<?php the_author_meta( '_spouse_date_of_baptism', $current_user->ID ); ?>"/> </div><!-- .spouse date of baptism --> </div> </div> <div class="form-submit"> <?php echo $referer; ?> <input type="hidden" name="action" value="update" /> <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user->ID); ?>" /> <?php wp_nonce_field('update-user_'.$current_user->ID); ?> <input name="action" type="hidden" id="action" value="update-user" /> <input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e("UPDATE PROFILE", 'profile'); ?>" /> </div><!-- .form-submit --> </form><!-- #adduser -->
- The topic ‘Filter 'edit_user_avatar' not working’ is closed to new replies.