Forked from azizultex/Frontend Edit Profile Page Wordpress
Created
February 7, 2017 18:39
-
-
Save FSahinn/7ddd7f36caa8803d4ba97f1aceaa35ea to your computer and use it in GitHub Desktop.
Frontend Edit Profile Page Wordpress
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 | |
/* | |
Template Name: Frontend Edit Profile | |
*/ | |
get_header(); | |
if ( is_user_logged_in() ) : { | |
$user_ID = get_current_user_id(); | |
$user_info = get_userdata($user_ID); | |
/* Personal Info */ | |
$malingaddrr = get_user_meta( $user_ID, 'malingaddrr', true ); | |
$city = get_user_meta( $user_ID, 'city', true ); | |
$state = get_user_meta( $user_ID, 'state', true ); | |
$province = get_user_meta( $user_ID, 'province', true ); | |
$country = get_user_meta( $user_ID, 'country', true ); | |
$aboutme = $user_info->description; | |
$sponsorship = get_user_meta( $user_ID, 'sponsorship', true ); | |
/* category selection */ | |
$arts = get_user_meta( $user_ID, 'arts', true ); | |
$design = get_user_meta( $user_ID, 'design', true ); | |
$film_video = get_user_meta( $user_ID, 'film_video', true ); | |
$music_checkbox = get_user_meta( $user_ID, 'music_checkbox', true ); | |
$sports = get_user_meta( $user_ID, 'sports', true ); | |
$theater = get_user_meta( $user_ID, 'theater', true ); | |
$dance = get_user_meta( $user_ID, 'dance', true ); | |
$fashion = get_user_meta( $user_ID, 'fashion', true ); | |
$food = get_user_meta( $user_ID, 'food', true ); | |
$photography = get_user_meta( $user_ID, 'photography', true ); | |
$technology = get_user_meta( $user_ID, 'technology', true ); | |
/* Social Media */ | |
$facebook = get_user_meta( $user_ID, 'facebook', true ); | |
$twitter = get_user_meta( $user_ID, 'twitter', true ); | |
$linkedin = get_user_meta( $user_ID, 'linkedin', true ); | |
$googleplus = get_user_meta( $user_ID, 'googleplus', true ); | |
$youtube = get_user_meta( $user_ID, 'youtube', true ); | |
$instagram = get_user_meta( $user_ID, 'instagram', true ); | |
$tumblr = get_user_meta( $user_ID, 'tumblr', true ); | |
/* website */ | |
$website = $user_info->user_url; | |
/*Users info */ | |
$username = $user_info->user_login; | |
// $userpass = $user_info->user_pass; | |
$fname = $user_info->first_name; | |
$lname = $user_info->last_name; | |
//$fname = get_user_meta( $user_ID, 'first_name', true ); | |
//$lname = get_user_meta( $user_ID, 'last_name', true ); | |
$email = $user_info->user_email; | |
if(isset($_POST['update_user_info'])) | |
{ | |
do_action('edit_user_profile_update', $user_ID); | |
/* Change Password http://cubiq.org/front-end-user-registration-and-login-in-wordpress */ | |
if ( !empty($_POST['current_pass']) && !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) { | |
if ( !wp_check_password( $_POST['current_pass'], $user_info->user_pass, $user_ID) ) { | |
$error = 'Your current password does not match. Please retry.'; | |
} elseif ( $_POST['pass1'] != $_POST['pass2'] ) { | |
$error = 'The passwords do not match. Please retry.'; | |
} elseif ( strlen($_POST['pass1']) < 4 ) { | |
$error = 'Password too short'; | |
} elseif ( false !== strpos( wp_unslash($_POST['pass1']), "\\" ) ) { | |
$error = 'Password may not contain the character "\\" (backslash).'; | |
} else { | |
$error = wp_update_user( array( 'ID' => $user_ID, 'user_pass' => esc_attr( $_POST['pass1'] ) ) ); | |
if ( !is_int($error) ) { | |
$error = 'An error occurred while updating your profile. Please retry.'; | |
} else { | |
$error = false; | |
} | |
} | |
echo "<strong>$error</strong>"; | |
} | |
$userdata = wp_update_user( array( 'ID' => $user_ID, 'first_name' => $_POST['fname'], 'last_name' => $_POST['lname'], 'user_email' => esc_attr( $_POST['email']), 'description' => esc_attr( $_POST['aboutme']), 'user_url' => esc_attr( $_POST['website']))); | |
if ( is_wp_error( $userdata ) ) { | |
echo 'Failed to Updated'; | |
} else { | |
echo '<strong>Profile Updated</strong>'; | |
} | |
} | |
} | |
?> | |
<div id="custom_reg_form"> | |
<form id="your-profile" action="" method="POST"> | |
<h3>SpartanGlory Registration</h3> | |
<ul class="adduser_from"> | |
<li> | |
<label for="user_name">Username</label> | |
<input type="text" name="user_name" value="<?php echo $username; ?>" disabled="disabled" /> | |
</li> | |
<li> | |
<label for="password">Current Password</label> | |
<input type="password" name="current_pass" /> | |
</li> | |
<li> | |
<label for="password">New Password</label> | |
<input type="password" name="pass1" /> | |
</li> | |
<li> | |
<label for="password">Confirm Password</label> | |
<input type="password" name="pass2" /> | |
</li> | |
</ul> | |
<div class="clear"></div> | |
<h3>Personal Information</h3> | |
<ul class="Personal_info"> | |
<li> | |
<label for="fname">First Name</label> | |
<input type="text" name="fname" value="<?php echo $fname; ?>" /> | |
</li> | |
<li> | |
<label for="lname">Last Name</label> | |
<input type="text" name="lname" value="<?php echo $lname; ?>" /> | |
</li> | |
<li> | |
<label for="malingaddrr">Mailing Address</label> | |
<input type="text" name="malingaddrr" value="<?php echo $malingaddrr; ?>" /> | |
</li> | |
<li> | |
<label for="city">City</label> | |
<input type="text" name="city" value="<?php echo $city; ?>" /> | |
</li> | |
<li> | |
<label for="state">State</label> | |
<input type="text" name="state" value="<?php echo $state; ?>" /> | |
</li> | |
<li> | |
<label for="province">Province</label> | |
<input type="text" name="province" value="<?php echo $province; ?>" /> | |
</li> | |
<li> | |
<label for="country">Country</label> | |
<input type="text" name="country" value="<?php echo $country; ?>" /> | |
</li> | |
<li> | |
<label for="aboutme">About Me</label> | |
<textarea name="aboutme" id="fullwidth"><?php echo $aboutme; ?></textarea> | |
</li> | |
<li> | |
<label for="sponsorship">Why I/We Seek Sponsorship?</label> | |
<textarea name="sponsorship" id="fullwidth"><?php echo $sponsorship; ?></textarea> | |
</li> | |
</ul> | |
<h5>Select A Category</h5> | |
<ul id="category_items"> | |
<li><?php printf('<input type="checkbox" name="arts" value="enabled" %1$s />', checked( $arts, 'enabled', false )); ?><span class="description"><?php _e('Arts'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="design" value="enabled" %1$s />', checked( $design, 'enabled', false )); ?><span class="description"><?php _e('Design'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="film_video" value="enabled" %1$s />', checked( $film_video, 'enabled', false )); ?><span class="description"><?php _e('Film & Video'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="music_checkbox" value="enabled" %1$s />', checked( $music_checkbox, 'enabled', false )); ?><span class="description"><?php _e('Music'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="sports" value="enabled" %1$s />', checked( $sports, 'enabled', false )); ?><span class="description"><?php _e('Sports'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="theater" value="enabled" %1$s />', checked( $theater, 'enabled', false )); ?><span class="description"><?php _e('Theater'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="dance" value="enabled" %1$s />', checked( $dance, 'enabled', false )); ?><span class="description"><?php _e('Dance'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="fashion" value="enabled" %1$s />', checked( $fashion, 'enabled', false )); ?><span class="description"><?php _e('Fashion'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="food" value="enabled" %1$s />', checked( $food, 'enabled', false )); ?><span class="description"><?php _e('Food'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="photography" value="enabled" %1$s />', checked( $photography, 'enabled', false )); ?><span class="description"><?php _e('Photography'); ?></span></li> | |
<li><?php printf('<input type="checkbox" name="technology" value="enabled" %1$s />', checked( $technology, 'enabled', false )); ?><span class="description"><?php _e('Technology'); ?></span></li> | |
<div class="clear"></div> | |
<h3>Contact & Social Media</h3> | |
<ul class="social_media_info"> | |
<li> | |
<label for="email">Email Address</label> | |
<input type="email" name="email" value="<?php echo $email; ?>" /> | |
</li> | |
<li> | |
<label for="youtube">Youtube Channel</label> | |
<input type="text" name="youtube" value="<?php echo $youtube; ?>" /> | |
</li> | |
<li> | |
<label for="facebook">Facebook URL</label> | |
<input type="text" name="facebook" value="<?php echo $facebook; ?>" /> | |
</li> | |
<li> | |
<label for="twitter">Twitter ID</label> | |
<input type="text" name="twitter" value="<?php echo $twitter; ?>" /> | |
</li> | |
<li> | |
<label for="instagram">Instagram</label> | |
<input type="text" name="instagram" value="<?php echo $instagram; ?>" /> | |
</li> | |
<li> | |
<label for="linkedin">LinkedIn</label> | |
<input type="text" name="linkedin" value="<?php echo $linkedin; ?>" /> | |
</li> | |
<li> | |
<label for="tumblr">Tumblr</label> | |
<input type="text" name="tumblr" value="<?php echo $twitter; ?>" /> | |
</li> | |
<li> | |
<label for="googleplus"> Google Plus ID</label> | |
<input type="text" name="googleplus" value="<?php echo $googleplus; ?>" /> | |
</li> | |
</ul> | |
<div class="clear"></div> | |
<?php | |
$myAv = new simple_local_avatars(); | |
$myAv->edit_user_profile($user_info); | |
?> | |
<h3>Links</h3> | |
<ul class="links_im"> | |
<li> | |
<label for="website">Personal Website</label> | |
<input type="url" name="website" value="<?php echo $website; ?>" /> | |
</li> | |
</ul> | |
<div class="clear"></div> | |
<input type="submit" name="update_user_info" value="Update"/> | |
</form> | |
</div> | |
<?php | |
else : | |
{ | |
echo 'This section is for logged In Users only!'; | |
} | |
endif; | |
get_footer(); | |
?> |
Hocam halettim. Her şeyi kodda bazı düzenlemeler yaptım. Sorun yok şimdi. Kod tamamen çalışıyor. Teşekkür ederim.
Hocam Merhaba özel yazı türünü ön uçta düzenlemek ve kaydetmek için kod var mı?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mehmetsarr bu kodlar farklı dosyalarla bağlantılı olduğundan örnek “website” tanımlı değil diye hata veriyor. Müsait olursam yeni bir kod yazar paylaşırım.