I am totally new to wordpress and acf and I'm trying to use a user field in a post to show the author of the post. I tried to programatically add the post author id as a meta attribute in the wp_postmeta table like this:
update_field('video_author', get_current_user_id(), $post_id);
The post author, however, is not shown:
What am I doing wrong?
Also when I click the user field no users are listed. I presume acf looks for users in either "wp_users" or "users" table, both of which contain records. However, this is shown:
Thank you in advance.
I am totally new to wordpress and acf and I'm trying to use a user field in a post to show the author of the post. I tried to programatically add the post author id as a meta attribute in the wp_postmeta table like this:
update_field('video_author', get_current_user_id(), $post_id);
The post author, however, is not shown:
What am I doing wrong?
Also when I click the user field no users are listed. I presume acf looks for users in either "wp_users" or "users" table, both of which contain records. However, this is shown:
Thank you in advance.
Share Improve this question asked Aug 19, 2020 at 13:41 Nikolay NaydenovNikolay Naydenov 1 2- If this is a regular post, the author is already saved in the database. Even if you create the post programatically, if that script is triggered by the logged in user, that user will be the post's author. – NightHawk Commented Aug 19, 2020 at 17:22
- @NightHawk But how to I show this user in my post edit page? – Nikolay Naydenov Commented Aug 21, 2020 at 10:28
1 Answer
Reset to default 0If you are using ACF then you don't need to update field manually. Field will be updated when you update the post.
And To retrieve this field use :
get_field( 'video_author', $post_id );
For User field, make sure you have selected Field Type -> User in ACF.