Created
December 8, 2012 18:25
-
-
Save wanye71/4241237 to your computer and use it in GitHub Desktop.
user frontend image upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Processing Section | |
global $current_user, $wp_roles; | |
get_currentuserinfo(); | |
/* Load the registration file. */ | |
require_once( ABSPATH . WPINC . '/registration.php' ); | |
/* If profile was saved, update profile. */ | |
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' ) { | |
/* Update user information. */ | |
if ( !empty( $_POST['image'] ) ) | |
update_usermeta( $current_user->id, 'user_image', esc_url( $_POST['image'] ) ); | |
/* Redirect so the page will show updated info. */ | |
if ( !$error ) { | |
wp_redirect( get_permalink() ); | |
exit; | |
} | |
} | |
?> | |
<form method="post" enctype="multipart/form-data"> | |
<input type="hidden" name="size" value="350000"> | |
<input type="file" name="user_image"> | |
<?php echo $referer; ?> | |
<input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Update', 'profile'); ?>" /> | |
<?php wp_nonce_field( 'update-user' ) ?> | |
<input name="action" type="hidden" id="action" value="update-user" /> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment