Home › Forums › Front-end Issues › To create a link to edit a front form?
I created an external form, and is working perfectly fine. But I would like my users have the option to edit your posts via a link in a front form.
Loading the content to be edited in the same form!
Basically I’m creating a theme type classified.
I appreciate any hint or help.
I also would like to create a “Dashboard” Page for each user and would like to list his posts which he can edit.
I have the WordPress Front End User Pro and I already created the login and the dashboard page. Now I would need the links to ACF Edit Forms for each post and posttype.
(and no – I don’t want to use the WPFront End User Pro Forms as they do not support galleries)
I am using this way!
Edit post url:
http://website.com/editformpage/?post_id=<?php echo get_the_ID();?>
//form.php template
<?php if ( is_user_logged_in() ) { ?>
<?php acf_form(array(
'field_groups' => array(xx),
'post_id' => 'myid',
'submit_value' => 'Submit',
'return' => '%post_url%',
'updated_message' => ''
)); ?>
<?php } else { ?>
Login Form
<?php } ?>
//editform.php template
<?php if ( is_user_logged_in() ) { ?>
<?php
$post_id = $_GET['post_id']; // get post_id option
$options = array(
'post_id'=> $post_id,
);
acf_form($options);
?>
<?php if ( is_user_logged_in() ) : ?>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php acf_form(array(
'field_groups' => array(xx),
'post_id' => $post_id,
'post_title' => false,
'return' => '%post_url%',
'submit_value' => 'Update'
)); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php } else { ?>
Login Form
<?php } ?>
One Question – why is the acf_form() two times in the editform.php template?
Somehow my forms are not saving (I am using the acf_form_head(); function)
<?php
/*
Template Name: Form Edit
*/
acf_form_head();
get_header();
the_post();
?>
<div class="acfform">
<?php
$post_id = $_GET['post_id']; // get post_id option
$options = array(
'post_id'=> $post_id,
);
acf_form($options);
?>
<?php if ( is_user_logged_in() ) : ?>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php acf_form(array(
'field_groups' => array(xxxxxxxxxxx),
'post_id' => $post_id,
'post_title' => false,
'return' => '%post_url%',
'submit_value' => 'Atualizar Anuncio'
)); ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php
/*
Template Name: Form ADD
*/
acf_form_head();
get_header();
the_post();
?>
<div class="acfform">
<?php acf_form(array(
'field_groups' => array(xxxxxxxxx),
'post_id' => 'xxxxx',
'submit_value' => 'ADD',
'return' => '%post_url%',
'updated_message' => ''
)); ?>
</div>
The topic ‘To create a link to edit a front form?’ is closed to new replies.
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.