最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - ACF unable to use user field

programmeradmin3浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

If 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.

发布评论

评论列表(0)

  1. 暂无评论