I would greatly appreciate any help you can provide regarding the creation of a front end form to allow members to edit custom posts that I have created in their admin panel.

I have successfully created the custom posts with the following code in functions.php as follows:

    /**Add custom fields to the user profile**/
    add_action( 'show_user_profile', 'premises_information_users_fields' );
    add_action( 'edit_user_profile', 'premises_information_users_fields' );
    function premises_information_users_fields( $user ) { ?>
      <h3>Premises Self-Inspection Schedule</h3>
            $wheelchair = get_user_meta( $user->ID, 'wheelchair', true );
            <th><label for "wheelchair">Do you have wheelchair access for disabled clients? Yes or No</label></th>
                <input type="text" name="wheelchair" id="wheelchair" value="<?php echo esc_attr($wheelchair) ?>" class="regular-text">
            $wheelchair_comments = get_user_meta($user->ID, 'wheelchair_comments', true);
                <th><label for "wheelchair_comments">Comments</label></th>
                <input type="text" name="wheelchair_comments" id="wheelchair_comments" value="<?php echo esc_attr($wheelchair_comments) ?>" class="regular-text">

 <?php }

add_action( 'personal_options_update', 'save_premises_information_users_fields' );
add_action( 'edit_user_profile_update', 'save_premises_information_users_fields' );
function save_premises_information_users_fields( $user_id ) {
    if( !isset( $_POST[ '_wpnonce' ] ) || !wp_verify_nonce( $_POST[ '_wpnonce' ], 'update-user_' . $user_id ) ) {
    if( !current_user_can( 'edit_user', $user_id ) ) {
    update_user_meta($user_id, 'wheelchair', $_POST['wheelchair'] );
    update_user_meta($user_id, 'wheelchair_comments', $_POST['wheelchair_comments']);

There are many more fields, but they all follow this format: it works great for the backend, saves and updates within the admin panel.

What I am trying to achieve is a front-end page where users can see and edit the custom fields that have been created in the backend.

I understand that this should be achieved by creating a new template page based on the current page.php and adding in the code to display / allow users to update their own member information from the front end.

The current page.php looks like this:

 * This is the current page.php that needs to be amended 
    to include the code to allow a member to update 
    and edit their information with the custom fields
    created above. 



<?php get_header(); ?>

<div id="main-content"<?php highend_main_content_style(); ?>>

    <div class="container">
        <div class="row main-row <?php echo highend_get_page_layout(); ?>">

            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                <div id="page-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <?php do_action( 'highend_main_content_start' ); ?>


                    wp_link_pages( array(
                        'before' => '<div id="hb-page-links">' . esc_html__( 'Pages:', 'hbthemes' ),
                        'after'  => '</div>',
                    ) );
                    if ( comments_open() && highend_option( 'hb_disable_page_comments' ) ) {

                    <?php do_action( 'highend_main_content_end' ); ?>

            <?php endwhile; endif; ?>   

        </div><!-- END .row -->

    </div><!-- END .container -->

</div><!-- END #main-content -->

<?php get_footer(); ?>

Any help with the code to allow the custom fields to be edited by members on the front end would be hugely appreciated!

  • I did something similar with a few functions the plugin Advanced Custom Fields provides. I found it rather easy to handle, although it still is quite tricky. If you want to go down this path you may want to have a look at acf_form() and acf_register_form() over here: advancedcustomfields.com/resources/acf_form Jan 24 at 16:04
  • Thank you very much for this suggestion. I created a solution using Advanced Custom Fields as suggested and it is working well, so the client is happy. I would still be interested to know the "raw code" solution if anyone has it! Thanks again for taking the time to reply with this solution. Feb 8 at 9:49


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.