Support

Account

Home Forums Front-end Issues Saving front end form to user profile

Solved

Saving front end form to user profile

  • Hi there. I have added a set of fields to the user profile, and it works perfectly in the back end. It includes a repeater field, for which each row in the repeater includes an image upload, a text box and a text area.

    I have also been able to make the form appear on the front end successfully. However, when I click to update the form on the front end, nothing happens – the page doesn’t refresh and nothing is saved to the user’s profile.

    One other element of this is that I am trying to have the form display on the front end as part of a form from WP User Frontend Pro, as I am using their interface for various user profile customisations, etc. So I am not sure if this complicates matters.

    I’m hoping you can offer some advice as to what I should do. I spent time going through the forums and docs over the weekend, but couldn’t seem to solve my problem.

    Thanks for your time.

    Best wishes, Andrew.

  • Hi @abaloo

    I am yet to do any testing with WP User Frontend Pro and ACF, so I can’t confirm if it could work at all.

    Can you post your code which you are using to render the form?
    Have you included the acf_form_head function on the page to allow the saving?

    Thanks
    E

  • Hi Elliot.

    Many thanks for your reply. At the moment I’ve just been trying to get it to work inside of twentythirteen so I rule out any theme issues. So it’s in the standard twentythirteen page (page-18.php to be precise, which is just a duplicate of page.php to try this code) with your code added. The shortcode for the WP User Frontend Pro form is included in the WP admin page editor and output (correctly) by the_content() as usual. I am using the acf_form_head function. The full page code is as follows:

    <?php
    
    acf_form_head();
    
    /**
     * The template for displaying all pages
     *
     * This is the template that displays all pages by default.
     * Please note that this is the WordPress construct of pages and that other
     * 'pages' on your WordPress site will use a different template.
     *
     * @package WordPress
     * @subpackage Twenty_Thirteen
     * @since Twenty Thirteen 1.0
     */
    
    get_header(); ?>
    
    	<div id="primary" class="content-area">
    		<div id="content" class="site-content" role="main">
    
    			<?php /* The loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    					<header class="entry-header">
    						<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
    						<div class="entry-thumbnail">
    							<?php the_post_thumbnail(); ?>
    						</div>
    						<?php endif; ?>
    
    						<h1 class="entry-title"><?php the_title(); ?></h1>
    					</header><!-- .entry-header -->
    
    					<div class="entry-content">
    						<?php the_content(); ?>
    						<?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
    					</div><!-- .entry-content -->
    
    					<footer class="entry-meta">
    						<?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
    					</footer><!-- .entry-meta -->
    				</article><!-- #post -->
    
    		
    			<?php endwhile; ?>
    
    <?php 	$args = array(
    				'user_id' => '2',
    				'field_groups' => array( 57 )
    			);
     
    			acf_form( $args ); 
    ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  • Hi @abaloo

    I can see the issue is you are using a $args parameter called ‘user_id’. This arg does not exist and you need to use the ‘post_id’ arg instead like so:

    
    'post_id' => 'user_2'
    

    Hope that helps.

    Thanks
    E

  • Hi Eliot. Thanks for this. I’d not realised you’d responded as I received no notification of this response for some reason.

    Many thanks for the response – I’ll give that a go. Is there any way that this can be made to be dynamic – so that it works for whichever user is viewing the page (a hard-coded user ID won’t really be much good)?

    Thanks again for your time.

    Best wishes, Andrew.

  • Hi @abaloo

    PHP allows you to create dynamic content very easily.
    ‘user_2’ can be ‘user_’ . $user_id

    Thanks
    E

  • Thanks Eliot. I’m not sure what made me think that ACF would be different from standard WordPress PHP here – but thanks for being patient.

    Have a fabulous Christmas and a very healthy new year – and thanks again for this amazing plugin.

    Best wishes, Andrew.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Saving front end form to user profile’ is closed to new replies.