Hello!
If you want to use a generic page such as /edit-post
that display a form which edit a specific post from the current logged user seeing the page, you’ll have to pass post id you want that form update as explained in the Passing Data to a Form tutorial.
It can be represented like this:
add_filter('acfe/form/load/form=edit_page', 'my_form_edit_page', 10, 2);
function my_form_edit_page($form, $post_id){
// get current user id
$user_id = get_current_user_id();
// no user id, hide the form
if(!$user_id){
return false;
}
// get the "band" post where the current user is author
$get_user_posts = get_posts(array(
'post_type' => 'band',
'posts_per_page' => 1,
'author' => $user_id
));
// no band post found, hide the form
if(empty($get_user_posts)){
return false;
}
// get the first post id found in the query results
$post_id_to_edit = $get_user_posts[0];
// pass 'post_to_edit' to the form
// this can be retrieved in the Form UI
// using {form:post_tot_edit} as "Target" or "Load source" in the Post Action settings
$form['post_to_edit'] = $post_id_to_edit;
// return form
return $form;
}
You can then use the {form:post_to_edit}
Template Tag in the Form UI, as Post Action “Target” and “Load Source” settings for example.
Hope it helps!
Have a nice day!
Regards.