Hello everyone, i have a new one here.
I’ve have already on my page a custom post type called, ‘Musicians’ and on ACF custom fields, location is post type = musician. All good.
All musicians have been posted by admin, but i’ve created a new role called ‘artist’ and every musician with this user role is now able to edit his own page. I have assigned the existing musician to the user, so now the artist is the post author of the page. In fact, everything works good, i’ve created some new fields and a new custom post. Everything is done on front end with acf form and works.
The new scenario now is, a user logs in and is redirected to a user page with a couple of forms that once filled are displayed on his own the page.
There are already a gallery and a text field on the page that come from the ‘musician’ post type:
How can i display these existing fields and be able to edit them based on post author on the the user page i creatated? If i include the rules of user role or current user role on ‘musician’ they don’t show up. And if i put the fields with <?php echo do_shortcode(‘[my_acf_user_form field_group=””]’); ?> it’s all empty.
I think the question its just, how can a not admin user edit a custom post type field on a front end form, but only for the post or page that the user is the author?
All right!!! Got it, I’m using acf_form array(),
in post_id => get_the_ID(). In case someone needs something like this:
'post_id' => get_the_ID(),
'field_groups' => array(xxx,xxx), // Used ID of the field groups here.
'post_title' => false, // This will show the title filed
'post_content' => false, // This will show the content field
'author' => $current_user->ID,
'form' => true,
'submit_value' => 'Update the post!'