Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Template Name: Agent Profile */
- /* Get user info. */
- global $current_user, $wp_roles;
- //get_currentuserinfo(); //deprecated since 3.1
- /* Load the registration file. */
- //require_once( ABSPATH . WPINC . '/registration.php' ); //deprecated since 3.1
- $error = array();
- /* If profile was saved, update profile. */
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' ) {
- /* Update user password. */
- if ( !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) {
- if ( $_POST['pass1'] == $_POST['pass2'] )
- wp_update_user( array( 'ID' => $current_user->ID, 'user_pass' => esc_attr( $_POST['pass1'] ) ) );
- else
- $error[] = __('The passwords you entered do not match. Your password was not updated.', 'profile');
- }
- /* Update user information. */
- if ( !empty( $_POST['url'] ) )
- wp_update_user( array( 'ID' => $current_user->ID, 'user_url' => esc_url( $_POST['url'] ) ) );
- if ( !empty( $_POST['email'] ) ){
- if (!is_email(esc_attr( $_POST['email'] )))
- $error[] = __('The Email you entered is not valid. please try again.', 'profile');
- elseif(email_exists(esc_attr( $_POST['email'] )) != $current_user->id )
- $error[] = __('This email is already used by another user. try a different one.', 'profile');
- else{
- wp_update_user( array ('ID' => $current_user->ID, 'user_email' => esc_attr( $_POST['email'] )));
- }
- }
- if ( !empty( $_POST['first-name'] ) )
- update_user_meta( $current_user->ID, 'first_name', esc_attr( $_POST['first-name'] ) );
- if ( !empty( $_POST['last-name'] ) )
- update_user_meta($current_user->ID, 'last_name', esc_attr( $_POST['last-name'] ) );
- if ( !empty( $_POST['description'] ) )
- update_user_meta( $current_user->ID, 'description', esc_attr( $_POST['description'] ) );
- /* Redirect so the page will show updated info.*/
- /*I am not Author of this Code- i dont know why but it worked for me after changing below line to if ( count($error) == 0 ){ */
- if ( count($error) == 0 ) {
- //action hook for plugins and extra fields saving
- do_action('edit_user_profile_update', $current_user->ID);
- wp_redirect( get_permalink() );
- exit;
- }
- }
- get_header(); ?>
- <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
- <div id="post-<?php the_ID(); ?>">
- <div class="entry-content entry">
- <?php the_content(); ?>
- <?php if ( !is_user_logged_in() ) : ?>
- <p class="warning">
- <?php _e('You must be logged in to edit your profile.', 'profile'); ?>
- </p><!-- .warning -->
- <?php else : ?>
- <?php if ( count($error) > 0 ) echo '<p class="error">' . implode("<br />", $error) . '</p>'; ?>
- <form method="post" id="adduser" enctype="multipart/form-data" action="<?php the_permalink(); ?>">
- <!-- NEW PROFILE LAYOUT -->
- <!-- MAIN CONTAINER -->
- <div class="psecmain">
- <!-- FIRST SECTION -->
- <div class="psections">
- <!-- THE HEADING -->
- <h2>General Details</h2>
- <hr>
- <!-- END THE HEADING -->
- <!-- THE FIELDS -->
- <div>
- <!-- PROFILE PICTURE -->
- <div class="full-divsn"><h4>Upload Image</h4>
- <?php $image_attributes = wp_get_attachment_image_src( get_usermeta($user_id,'_thumbnail_id',true )); // returns an array
- echo '<img src="'.$image_attributes[0].'">'; ?>
- <p><?php _e('Upload image that are best clicked for better appearance of your profile','framework'); ?></p>
- <div class="full-divsn mbottom2">
- <div class="col-md-8 col-sm-8 submit-image">
- <input type="file" name="agent-image">
- </div>
- </div>
- </div>
- <!-- END PROFILE PICTURE -->
- <!-- AGENT NAME -->
- <div class="full-divsn"><h4>Name</h4>
- <div class="full-divsn">
- <div class="col-md-4 col-sm-4">
- <input type="text" name="first_name" id="first_name" value="<?php echo $userdata->first_name; ?>" class="form-control first_name" placeholder="<?php _e('First Name','framework'); ?>" required>
- </div>
- <div class="col-md-4 col-sm-4">
- <input type="text" name="last_name" id="last_name" class="form-control last_name" value="<?php echo $userdata->last_name; ?>" placeholder="<?php _e('Last Name','framework'); ?>" required>
- </div>
- </div></div>
- <!-- END AGENT NAME -->
- <!-- COMPANY INFO -->
- <div class="full-divsn"><h4>Company</h4>
- <div class="full-divsn">
- <div class="col-md-4 col-sm-4">
- <input type="text" name="uagency" id="uagency" value="<?php echo $userdata->uagency; ?>" class="form-control uagency" placeholder="<?php _e('Agency','framework'); ?>" required>
- </div>
- </div>
- <div class="full-divsn">
- <div class="col-md-4 col-sm-4">
- <input type="text" name="utitle" id="utitle" value="<?php echo $userdata->utitle; ?>" class="form-control utitle" placeholder="<?php _e('Title','framework'); ?>" required>
- </div>
- </div></div>
- <!-- END COMPANY INFO -->
- <!-- CONTACT INFO -->
- <div class="full-divsn"><h4>Contact</h4>
- <div class="full-divsn">
- <div class="col-md-4 col-sm-4">
- <input type="text" value="<?php the_author_meta( 'mobile-phone', $current_user->ID ); ?>" name="mobile-phone" id="mobile-phone" class="form-control mobile-phone" placeholder="<?php _e('Mobile Phone','framework'); ?>">
- </div>
- <div class="col-md-4 col-sm-4">
- <input type="text" value="<?php the_author_meta( 'work-phone', $current_user->ID ); ?>" name="work-phone" id="work-phone" class="form-control work-phone" placeholder="<?php _e('Work Phone','framework'); ?>" required>
- </div>
- </div>
- <div class="full-divsn">
- <div class="col-md-4 col-sm-4">
- <input type="text" name="ufax" id="ufax" value="<?php the_author_meta( 'ufax', $current_user->ID ); ?>" class="form-control ufax" placeholder="<?php _e('Fax','framework'); ?>">
- </div>
- <!-- Agent Email -->
- <div class="col-md-4 col-sm-4">
- <input type="email" id="email" value="<?php echo $userdata->user_email ?>" name="email" class="form-control email1" placeholder="<?php _e('Email','framework'); ?>" required>
- </div>
- <!-- End Agent Email -->
- </div></div>
- <!-- END CONTACT INFO -->
- <!-- LOCATION INFO -->
- <div class="full-divsn"><h4>Company</h4>
- <div class="full-divsn">
- <div class="col-md-6 col-sm-6">
- <input type="text" name="uaddress" id="uaddress" value="<?php the_author_meta( 'uaddress', $current_user->ID ); ?>" class="form-control uaddress" placeholder="<?php _e('Address','framework'); ?>">
- </div>
- <div class="col-md-2 col-sm-2">
- <input type="text" name="uunit" id="uunit" value="<?php the_author_meta( 'uunit', $current_user->ID ); ?>" class="form-control uunit" placeholder="<?php _e('Unit','framework'); ?>">
- </div>
- </div>
- <div class="full-divsn">
- <!-- Agent City and State -->
- <div class="col-md-4 col-sm-4">
- <input type="text" value="<?php echo $userdata->ucity; ?>" name="ucity" id="ucity" class="form-control" placeholder="<?php _e('City','framework'); ?>" required>
- </div>
- <div class="col-md-4 col-sm-4">
- <input type="text" value="<?php echo $userdata->ustate; ?>" name="ustate" id="ustate" class="form-control" placeholder="<?php _e('State','framework'); ?>" required>
- </div>
- <!-- End Agent City and State -->
- </div></div>
- <!-- END LOCATION INFO -->
- <!-- SOCIAL LINKS -->
- <div class="full-divsn"><h4>Social</h4>
- <div class="full-divsn">
- <!-- Agent Social Links -->
- <div class="col-md-3 col-sm-3">
- <input type="text" value="<?php echo esc_attr(get_the_author_meta('fb-link', $user_ID)); ?>" name="fb-link" id="fb-link" class="form-control" placeholder="<?php _e('Facebook','framework'); ?>">
- </div>
- <div class="col-md-3 col-sm-3">
- <input type="text" value="<?php echo esc_attr(get_the_author_meta('twt-link', $user_ID)); ?>" name="twt-link" id="twt-link" class="form-control" placeholder="<?php _e('Twitter','framework'); ?>">
- </div>
- <div class="col-md-3 col-sm-3">
- <input type="text" value="<?php echo esc_attr(get_the_author_meta('gp-link', $user_ID)); ?>" name="gp-link" id="gp-link" class="form-control" placeholder="<?php _e('Google Plus','framework'); ?>">
- </div>
- <div class="col-md-3 col-sm-3">
- <input type="text" value="<?php echo esc_attr(get_the_author_meta('msg-link', $user_ID)); ?>" name="msg-link" id="msg-link" class="form-control" placeholder="<?php _e('Message','framework'); ?>">
- </div>
- <!-- End Agent Social Links -->
- </div></div>
- <!-- END SOCIAL LINKS -->
- </div>
- <!-- END THE FIELDS -->
- </div>
- <!-- END FIRST SECTION -->
- <!-- SECOND SECTION -->
- <div class="psections">
- <!-- THE HEADING -->
- <h2>About Yourself</h2>
- <hr>
- <!-- END THE HEADING -->
- <!-- THE FIELDS -->
- <div>
- <!-- ABOUT BIO -->
- <div class="full-divsn"><h4>About Bio</h4>
- <div class="full-divsn mbottom2">
- <div class="col-md-8 col-sm-8">
- <textarea name="description" id="description" class="form-control margin-0" rows="5" cols="10" value="<?php the_author_meta( 'description', $current_user->ID ); ?>" placeholder="<?php _e('About Bio','framework'); ?>"><?php the_author_meta( 'description', $current_user->ID ); ?></textarea>
- </div>
- </div></div>
- <!-- END ABOUT BIO -->
- <!-- EXP AND SP -->
- <div class="full-divsn"><h4>Experience/Specialties</h4>
- <div class="full-divsn mbottom2">
- <div class="col-md-8 col-sm-8 submit-description">
- <textarea name="uexp" id="uexp" class="form-control margin-0" rows="5" cols="10" placeholder="<?php _e('Experience/Specialties','framework'); ?>" value="<?php the_author_meta( 'uexp', $current_user->ID ); ?>" ><?php the_author_meta( 'uexp', $current_user->ID ); ?></textarea>
- </div>
- </div></div>
- <!-- END EXP AND SP -->
- <!-- EDUCATION -->
- <div class="full-divsn mbottom2"><h4>Education</h4>
- <div class="full-divsn">
- <div class="col-md-8 col-sm-8">
- <textarea name="ueduc" id="ueduc" class="form-control ueduc margin-0" rows="5" cols="10" value="<?php the_author_meta( 'ueduc', $current_user->ID ); ?>" placeholder="<?php _e('Education','framework'); ?>"><?php the_author_meta( 'ueduc', $current_user->ID ); ?></textarea>
- </div>
- </div></div>
- <!-- END EDUCATION -->
- </div>
- <!-- END THE FIELDS -->
- </div>
- <!-- END SECOND SECTION -->
- </div>
- <!-- END MAIN CONTAINER -->
- <p class="form-submit">
- <?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" />
- </p><!-- .form-submit -->
- </form><!-- #adduser -->
- <?php endif; ?>
- </div><!-- .entry-content -->
- </div><!-- .hentry .post -->
- <?php endwhile; ?>
- <?php else: ?>
- <p class="no-data">
- <?php _e('Sorry, no page matched your criteria.', 'profile'); ?>
- </p><!-- .no-data -->
- <?php endif; ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement