[ad_1]
Hello,
Thanks for the feedback!
Yes, you could do it using two different methods:
1. Transparent method
Let’s say you only allow one post per user (ie: a profile page). Then you could create 2 pages:
/create-profile/update-profile
On the /create-profile page you add a form which create a ‘profile’ post type, with the currently logged user as author in the “Post Create Action”. Then you add “Redirect Action” to redirect the user on /update-profile.
On the /update-profile page, you could retrieve the profile post id of the currently logged user using a query, and then pass the profile page id to the form, like this:
// get current user profile page
$get_user_profile_page = get_posts(array(
'post_type' => 'profile',
'posts_per_page' => 1,
'author' => get_current_user_id(),
'fields' => 'ids'
));
// check the page exists
if($get_user_profile_page){
// retrive page id
$profile_page_id = current($get_user_profile_page);
// pass the profile page id to the form
acfe_form(array(
'name' => 'my-form-update',
'profile_page_id' => $profile_page_id
))
}The profile page id can then be used in your Form UI usign the Template Tag {form:profile_page_id}. You can use it within your Post Action “Update Target” to update that page. See documentation.
2. Using a param in the redirect URL
If you allow multiple posts per user, then you’ll have to pass the post id in the URL of the redirect. To do so, on the /create-profile form, in the “Redirect Action” you can use the following URL: /update-profile?profile_id={post:ID}.
{post:ID} will tell the Redirect Action to use the previous “Post Action” created post ID. See documentation about Template Tags.
Then on your /update-profile page you’ll have to retrieve that URL parameter using $_GET, do some security check (make sure the user has the right to edit that ID etc…) and display the update form by passing the profile page id like in the example 1.
Hope it helps!
Haver a nice day!
Regards.
