Support

Account

Home Forums Front-end Issues Frontend form submit button not working

Solving

Frontend form submit button not working

  • Hi, I’ve been testing a lot, searching, and nothing worked so I hope here can help me.
    I followed the documentation about how to post from frontend with ACF fields, I finally can see the form at frontend, but never works the submit button.
    I tested with other templates, desactivating other plugins, but nothing worked.
    I’m using v4 of ACF and last version of wordpress.
    Any ideas? Do I need the pro version to get it work? If is this the case, why can I show the form but not work the submit button??
    I added the code in the theme files and in the functions.php, but it’s the functions.php inside the theme folder or in the wp-includes? I tried in the last one but breaks the website.
    If someone can help me I will be so happy, I’ve been toons of hours trying to fix it by myself but nothing worked.
    Thanks for your time.

  • can you post your code

  • from my themes/evolve/functions.php

    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
    function my_pre_save_post( $post_id ) {
    	// bail early if not a new post
    	if( $post_id !== 'new_post' ) {
    		return $post_id;
    	}
    	// vars
    	$title = $_POST['fields']['post_title'];
    	$content = $_POST['fields']['post_content'];
    	// Create a new post
    	$post = array(
    		'post_status'	=> 'publish',
    		'post_type'		=> 'prueba',
    		'post_title'	=> $title,
    		'post_content'	=> $content
    	);	
    	// insert the post
    	$post_id = wp_insert_post( $post ); 
    	// return the new ID
    	return $post_id;
    }

    prueba is the name of my custom post type

    from my single-custom.php

    <?php acf_form_head(); ?>
    <?php get_header(); ?>
    
    	<div id="primary">
    		<div id="content" role="main">
    
    			<?php /* The loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php acf_form(array(
    		'post_id'		=> 'new_post',
    		'field_groups'	=> array( 577 )); ?>
    
    			<?php endwhile; ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    the name of the field for the title is post_title and for the content post_content, only tried this for if was a problem of compatibility with other fields, but anyway this not working anyway, how I said, it shows the form but the button doesn’t do anything.
    577 is the ID of my ACF group fields.

  • I’ve solved it thanks anyway.

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

The topic ‘Frontend form submit button not working’ is closed to new replies.