Skip to content

Instantly share code, notes, and snippets.

@Matteo182
Created April 3, 2020 17:36
Show Gist options
  • Save Matteo182/723a86079d87729c7646e595c1c97d12 to your computer and use it in GitHub Desktop.
Save Matteo182/723a86079d87729c7646e595c1c97d12 to your computer and use it in GitHub Desktop.
Front_end profile page in WordPress
<?php
/**
* The template for displaying user profile in front_end
*
* This is the template that displays user profile in fron_end.
*
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
get_header();
$container = get_theme_mod( 'understrap_container_type' );
?>
<div class="wrapper" id="page-wrapper">
<div class="<?php echo esc_attr( $container ); ?>" id="content" tabindex="-1">
<div class="row">
<!-- Do the left sidebar check -->
<?php get_template_part( 'global-templates/left-sidebar-check' ); ?>
<main class="site-main" id="main">
<?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" action="<?php the_permalink(); ?>">
<p class="form-username">
<label for="first-name"><?php _e('First Name', 'profile'); ?></label>
<input class="text-input" name="first-name" type="text" id="first-name" value="<?php the_author_meta( 'first_name', $current_user->ID ); ?>" />
</p><!-- .form-username -->
<p class="form-username">
<label for="last-name"><?php _e('Last Name', 'profile'); ?></label>
<input class="text-input" name="last-name" type="text" id="last-name" value="<?php the_author_meta( 'last_name', $current_user->ID ); ?>" />
</p><!-- .form-username -->
<p class="form-email">
<label for="email"><?php _e('E-mail *', 'profile'); ?></label>
<input class="text-input" name="email" type="text" id="email" value="<?php the_author_meta( 'user_email', $current_user->ID ); ?>" />
</p><!-- .form-email -->
<p class="form-url">
<label for="url"><?php _e('Website', 'profile'); ?></label>
<input class="text-input" name="url" type="text" id="url" value="<?php the_author_meta( 'user_url', $current_user->ID ); ?>" />
</p><!-- .form-url -->
<p class="form-password">
<label for="pass1"><?php _e('Password *', 'profile'); ?> </label>
<input class="text-input" name="pass1" type="password" id="pass1" />
</p><!-- .form-password -->
<p class="form-password">
<label for="pass2"><?php _e('Repeat Password *', 'profile'); ?></label>
<input class="text-input" name="pass2" type="password" id="pass2" />
</p><!-- .form-password -->
<p class="form-textarea">
<label for="description"><?php _e('Biographical Information', 'profile') ?></label>
<textarea name="description" id="description" rows="3" cols="50"><?php the_author_meta( 'description', $current_user->ID ); ?></textarea>
</p><!-- .form-textarea -->
<?php
//action hook for plugin and extra fields
do_action('edit_user_profile',$current_user);
?>
<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; ?>
</main><!-- #main -->
<!-- Do the right sidebar check -->
<?php get_template_part( 'global-templates/right-sidebar-check' ); ?>
</div><!-- .row -->
</div><!-- #content -->
</div><!-- #page-wrapper -->
<?php get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment