Home › Forums › Front-end Issues › Front end saving
Hi,
I am new to wordpress (10 years of joomla) and i am getting to like it. I hope the wordpress community is as nice as the joomla is. I have the followin issue.
I have created some fields and in the back end it saves fine when submitting a listing (property).
When i want to submit through the front-end is does save the new listing but it does not save the field created with ACF.
Here is my normal template file:
`<?php
/**
* Template Name: Submit Listing
*
* @package WP Real Estate 6
* @subpackage Template
*/
global $ct_options;
$inside_page_title = get_post_meta($post->ID, “_ct_inside_page_title”, true);
submit_listing();
get_header();
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<?php if($inside_page_title == “Yes”) { ?>
<div id=”page-header”>
<div class=”container”>
<h2 class=”left”><?php the_title(); ?></h1>
<?php ct_breadcrumbs(); ?>
<div class=”clear”></div>
</div>
</div>
<?php } ?>
<div class=”container marT30″>
<article class=”col span_12 first”>
<form action=”” id=”primaryPostForm” method=”POST” enctype=”multipart/form-data”>
<?php if ( $postTitleError != ” ) { ?>
<span class=”error”><?php echo $postTitleError; ?></span>
<div class=”clearfix”></div>
<?php } ?>
<div class=”col span_6 first”>
<div class=”input-full-width”>
<label><?php _e(‘Address’, ‘contempo’); ?></label>
<input type=”text” name=”postTitle” id=”postTitle” value=”<?php if ( isset( $_POST[‘postTitle’] ) ) echo $_POST[‘postTitle’]; ?>”/>
</div>
<div class=”col span_4 first”>
<label><?php _e(‘Type’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘property_type’); ?>
</div>
<div class=”col span_4″>
<label><?php _e(‘Status’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘ct_status’); ?>
</div>
<div class=”col span_4″>
<label><?php _e(‘Price’, ‘contempo’); ?></label>
<input type=”text” name=”customMetaPrice” id=”customMetaPrice” value=”<?php if(isset($_POST[‘customMetaPrice’])) echo $_POST[‘customMetaPrice’];?>” />
</div>
<div class=”clear”></div>
<label><?php _e(‘Listing Description’, ‘contempo’); ?></label>
<textarea name=”postContent” id=”postContent” rows=”8″ cols=”30″>
<?php
if ( isset( $_POST[‘postContent’] ) ) {
if ( function_exists( ‘stripslashes’ ) ) {
echo stripslashes( $_POST[‘postContent’] );
} else {
echo $_POST[‘postContent’];
}
}
?>
</textarea>
<div class=”left”>
<label><?php _e(‘Gallery Images (select as many as you like)’, ‘contempo’); ?></label>
<input type=”file” name=”galleryImages” id=”galleryImages” multiple=”” />
</div>
</div>
<div class=”col span_6″>
<div class=”col span_4 first”>
<label><?php _e(‘City’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxCity” id=”customTaxCity” value=”<?php if ( isset( $_POST[‘customTaxCity’] ) ) echo $_POST[‘customTaxCity’]; ?>”/>
</div>
<div class=”col span_4″>
<label><?php _e(‘State’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxState” id=”customTaxState” value=”<?php if ( isset( $_POST[‘customTaxState’] ) ) echo $_POST[‘customTaxState’]; ?>”/>
</div>
<div class=”col span_4″>
<label><?php _e(‘Zipcode’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxZip” id=”customTaxZip” value=”<?php if ( isset( $_POST[‘customTaxZip’] ) ) echo $_POST[‘customTaxZip’]; ?>”/>
</div>
<div class=”col span_4 first”>
<label><?php _e(‘Beds’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxBeds” id=”customTaxBeds” value=”<?php if(isset($_POST[‘customTaxBeds’])) echo $_POST[‘customTaxBeds’];?>” />
</div>
<div class=”col span_4″>
<label><?php _e(‘Baths’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxBaths” id=”customTaxBaths” value=”<?php if(isset($_POST[‘customTaxBaths’])) echo $_POST[‘customTaxBaths’];?>” />
</div>
<div class=”col span_4″>
<label><?php strtoupper(sqftsqm()); ?></label>
<input type=”text” name=”customMetaSqFt” id=”customMetaSqFt” value=”<?php if(isset($_POST[‘customMetaSqFt’])) echo $_POST[‘customMetaSqFt’];?>” />
</div>
<label><?php _e(‘Additional Features (separated)’, ‘contempo’); ?></label>
<textarea name=”customTaxFeat” id=”customTaxFeat” rows=”8″ cols=”30″>
<?php
if ( isset( $_POST[‘customTaxFeat’] ) ) {
if ( function_exists( ‘stripslashes’ ) ) {
echo stripslashes( $_POST[‘customTaxFeat’] );
} else {
echo $_POST[‘customTaxFeat’];
}
}
?>
</textarea>
<div class=”left”>
<label><?php _e(‘Listing Featured Image’, ‘contempo’); ?></label>
<input type=”file” name=”featuredImage” id=”featuredImage” />
</div>
</div>
<div class=”col span_12 first marT40″>
<?php wp_nonce_field(‘post_nonce’, ‘post_nonce_field’); ?>
<input type=”hidden” name=”submitted” id=”submitted” value=”true” />
<input type=”submit” value=”<?php _e(‘Submit Listing’, ‘contempo’); ?>” tabindex=”5″ id=”submit” name=”submit” class=”btn” />
</div>
</form>
<?php wp_link_pages( array( ‘before’ => ‘<div class=”page-link”><span>’ . __( ‘Pages:’, ‘contempo’ ) . ‘</span>’, ‘after’ => ‘</div>’ ) ); ?>
<?php endwhile; endif; wp_reset_query(); ?>
<div class=”clear”></div>
</article>
<?php echo ‘<div class=”clear”></div>’;
echo ‘</div>’;
get_footer(); ?>
Here is the file when i show the form from acf at the front end.
<?php
/**
* Template Name: Submit Listing
*
* @package WP Real Estate 6
* @subpackage Template
*/
acf_form_head();
global $ct_options;
$inside_page_title = get_post_meta($post->ID, “_ct_inside_page_title”, true);
submit_listing();
get_header();
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<?php if($inside_page_title == “Yes”) { ?>
<div id=”page-header”>
<div class=”container”>
<h2 class=”left”><?php the_title(); ?></h1>
<?php ct_breadcrumbs(); ?>
<div class=”clear”></div>
</div>
</div>
<?php } ?>
<div class=”container marT30″>
<article class=”col span_12 first”>
<form action=”” id=”primaryPostForm” method=”POST” enctype=”multipart/form-data”>
<?php acf_form( $options ); ?>
<?php if ( $postTitleError != ” ) { ?>
<span class=”error”><?php echo $postTitleError; ?></span>
<div class=”clearfix”></div>
<?php } ?>
<div class=”col span_6 first”>
<div class=”input-full-width”>
<label><?php _e(‘Address’, ‘contempo’); ?></label>
<input type=”text” name=”postTitle” id=”postTitle” value=”<?php if ( isset( $_POST[‘postTitle’] ) ) echo $_POST[‘postTitle’]; ?>”/>
</div>
<div class=”col span_4 first”>
<label><?php _e(‘Type’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘property_type’); ?>
</div>
<div class=”col span_4″>
<label><?php _e(‘Status’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘ct_status’); ?>
</div>
<div class=”col span_4″>
<label><?php _e(‘Price’, ‘contempo’); ?></label>
<input type=”text” name=”customMetaPrice” id=”customMetaPrice” value=”<?php if(isset($_POST[‘customMetaPrice’])) echo $_POST[‘customMetaPrice’];?>” />
</div>
<div class=”clear”></div>
<label><?php _e(‘Listing Description’, ‘contempo’); ?></label>
<textarea name=”postContent” id=”postContent” rows=”8″ cols=”30″>
<?php
if ( isset( $_POST[‘postContent’] ) ) {
if ( function_exists( ‘stripslashes’ ) ) {
echo stripslashes( $_POST[‘postContent’] );
} else {
echo $_POST[‘postContent’];
}
}
?>
</textarea>
<div class=”left”>
<label><?php _e(‘Gallery Images (select as many as you like)’, ‘contempo’); ?></label>
<input type=”file” name=”galleryImages” id=”galleryImages” multiple=”” />
</div>
</div>
<div class=”col span_6″>
<div class=”col span_4 first”>
<label><?php _e(‘City’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxCity” id=”customTaxCity” value=”<?php if ( isset( $_POST[‘customTaxCity’] ) ) echo $_POST[‘customTaxCity’]; ?>”/>
</div>
<div class=”col span_4″>
<label><?php _e(‘State’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxState” id=”customTaxState” value=”<?php if ( isset( $_POST[‘customTaxState’] ) ) echo $_POST[‘customTaxState’]; ?>”/>
</div>
<div class=”col span_4″>
<label><?php _e(‘Zipcode’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxZip” id=”customTaxZip” value=”<?php if ( isset( $_POST[‘customTaxZip’] ) ) echo $_POST[‘customTaxZip’]; ?>”/>
</div>
<div class=”col span_4 first”>
<label><?php _e(‘Beds’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxBeds” id=”customTaxBeds” value=”<?php if(isset($_POST[‘customTaxBeds’])) echo $_POST[‘customTaxBeds’];?>” />
</div>
<div class=”col span_4″>
<label><?php _e(‘Baths’, ‘contempo’); ?></label>
<input type=”text” name=”customTaxBaths” id=”customTaxBaths” value=”<?php if(isset($_POST[‘customTaxBaths’])) echo $_POST[‘customTaxBaths’];?>” />
</div>
<div class=”col span_4″>
<label><?php strtoupper(sqftsqm()); ?></label>
<input type=”text” name=”customMetaSqFt” id=”customMetaSqFt” value=”<?php if(isset($_POST[‘customMetaSqFt’])) echo $_POST[‘customMetaSqFt’];?>” />
</div>
<label><?php _e(‘Additional Features (separated)’, ‘contempo’); ?></label>
<textarea name=”customTaxFeat” id=”customTaxFeat” rows=”8″ cols=”30″>
<?php
if ( isset( $_POST[‘customTaxFeat’] ) ) {
if ( function_exists( ‘stripslashes’ ) ) {
echo stripslashes( $_POST[‘customTaxFeat’] );
} else {
echo $_POST[‘customTaxFeat’];
}
}
?>
</textarea>
<div class=”left”>
<label><?php _e(‘Listing Featured Image’, ‘contempo’); ?></label>
<input type=”file” name=”featuredImage” id=”featuredImage” />
</div>
</div>
<div class=”col span_12 first marT40″>
<?php wp_nonce_field(‘post_nonce’, ‘post_nonce_field’); ?>
<input type=”hidden” name=”submitted” id=”submitted” value=”true” />
<input type=”submit” value=”<?php _e(‘Submit Listing’, ‘contempo’); ?>” tabindex=”5″ id=”submit” name=”submit” class=”btn” />
</div>
</form>
<?php wp_link_pages( array( ‘before’ => ‘<div class=”page-link”><span>’ . __( ‘Pages:’, ‘contempo’ ) . ‘</span>’, ‘after’ => ‘</div>’ ) ); ?>
<?php endwhile; endif; wp_reset_query(); ?>
<div class=”clear”></div>
</article>
<?php echo ‘<div class=”clear”></div>’;
echo ‘</div>’;
get_footer(); ?>
Old question and you’ve probably moved on by now and I don’t know if this will help anyone, but.
acf_form()
can’t be used inside an already existing form like this. For this you’d need to use some other functions that are not in the documentation. For something like this I would suggest starting by looking at how acf_form renders the field group, follow the code. Then if you have specific questions about getting it to work start a new topic.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.