Last active
August 29, 2015 14:12
-
-
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
This file contains 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: 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 →</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(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.