Skip to content

Instantly share code, notes, and snippets.

@DMSpeed
Last active August 29, 2015 14:12
Show Gist options
  • Save DMSpeed/98c15545dd19cb851817 to your computer and use it in GitHub Desktop.
Save DMSpeed/98c15545dd19cb851817 to your computer and use it in GitHub Desktop.
Genesis page template for updating the user's profile on the front end using acf_form
<?php
/**
* Template Name: Update Profile
* This template displays a form for updating the user's profile on the front end
* Based on https://daronspence.wordpress.com/2014/09/29/front-facing-user-profile-editing-customization-with-acf/
*/
acf_form_head();
get_header();
add_action ('genesis_entry_content', 'hgf_update_profile');
function hgf_update_profile() {
global $current_user;
get_currentuserinfo();
if ( !is_user_logged_in() ){
echo 'You are not logged in. <br /> <a href="' . get_permalink(31) .'">Log In &rarr;</a>';
}
else {
$options = array(
'post_id' => 'user_'.$current_user->ID,
'field_groups' => array(356,374), //IDs of profile field groups
'submit_value' => 'Update Your Profile',
'form' => true,
'return' => add_query_arg( 'updated', 'true', get_permalink() ),
'html_before_fields' => '',
'html_after_fields' => ''
);
echo '<p>Your username is <b>'.$current_user->user_login.'</b>. This cannot be changed.</p>';
echo acf_form( $options );
}
}
genesis();
@DMSpeed
Copy link
Author

DMSpeed commented Dec 30, 2014

Working from Daron Spence's tutorial at https://daronspence.wordpress.com/2014/09/29/front-facing-user-profile-editing-customization-with-acf/, this page template allows for the use of an Advanced Custom Fields form on the front end to let users update their profiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment