Hello,
Thanks for the feedback!
I’m sorry, but I’m not sure to fully understand what you’re trying to achieve. Can you please provide some screenshots and example of your use case?
Are you trying to use the ACFE Post Field? This is is reserved for back-end usage. On the other end the ACFE Form module is for front-end usage.
Which feature of the ACF Post Object field are you trying to use? Do you have any code to share?
Thanks!
Regards.
For summarizing too much, I did not express myself well, sorry.
I need users to create publications with the parent-child structure, it is for a page that makes series reviews and the chapters will be the child posts. I have already created the Hierarchical Post Type.
At the time of creating the post, the problem is with the “attributes > parent” field, since I do not know how to prevent users from choosing parent publications created by other users. If only it were a drop-down that shows the publications of the current user, it would work!
I’m testing the “Dynamic Forms” module, I see that it seems to have an option for what I need> https://ibb.co/pZh3rXM, but I don’t know how to use it. I’m combining it with the “Post Object” field to try and create the child posts, but I can’t get the parent to automatically assign the post.
I hope I have expressed myself better, thank you for your time ♥
Hello,
Okay I think I understand better now.
You can use the native acf/fields/post_object/query hook in order to customize the posts that are displayed within the ACF Post Object field. See documentation.
Here is a usage example to only display posts from the currently logged user:
add_filter('acf/fields/post_object/query/name=my_post_object', 'my_acf_fields_post_object_query', 10, 3);
function my_acf_fields_post_object_query($args, $field, $post_id){
// display only posts of the currently logged user
$args['author'] = get_current_user_id();
return $args;
}
Regarding the ACFE Form “Post Action”, you’ll have to make sure to select your Post Type that is hierarchical, and select the Post Object field in the “Post Parent” setting. See screenshot.
Once configured, the Post will be created as a child of the selected post on the front-end.
You’ll find the documentation of the Post Action here if you need further customization examples using PHP hooks.
Hope it helps!
Have a nice day!
Regards.
@hwk-fr I am using this code and it is still loading the posts of all users, code:
add_filter('acf/fields/post_object/query', 'my_acf_fields_post_object_query', 10, 3);
function my_acf_fields_post_object_query( $args, $field, $post_id ) {
// display only posts of the currently logged user
$args['author'] = get_current_user_id();
return $args;
}
I’ve been with this for days and it’s driving me crazy, could you make a custom code for me that works for me? I am willing to pay you, thank you !!
-
This reply was modified 4 years, 5 months ago by
gabrieluno.
Hello,
I just tested again the code, and it works fine. Here is the video of my test.
Note that it is important to target your field name in the hook, like this:
acf/fields/post_object/query/name=my_post_object
Otherwise it will target all post objects. Also note that this code will filter the field to display posts of the currently logged user. If the current visitor is not logged, then it will display all posts. You can tweak that with a if/else condition if needed.
Hope it helps!
Have a nice day!
Regards.
That is what I need, but for the parents selection field, as in this image:

Remember it is for a custom post type created with ACF Extended. Thanks for everything great @hwk-fr ♥
-
This reply was modified 4 years, 5 months ago by
gabrieluno.
Hello,
The metabox you’re showing is managed by WordPress, not by ACF.
I would recommend to make some research about “wordpress parent page attribute select query”. Here is one stackoverflow topic.
Hope it helps!
Regards.