You can use Advanced Custom Fields, ACF, to add fields to your users in the WordPress admin area, which is great! However, Oxygen's ACF integration can't yet retrieve data from those fields. This tutorial will cover retrieving an ACF field for the current post author and adding it to Oxygen dynamically. This tutorial assumes that you will already have assigned an ACF field group to your users.
First off, you will need to install your favourite scripts plugin, such as Advanced Scripts (paid) or Code Snippets (free). I personally use Advanced Scripts as I think the interface is fantastic, but prior to that, I'd used Code Snippets for a number of years.
Once you've installed the scripts plugin of your choice, you can create a new snippet with the following code:
Next, edit your posts template. To retrieve your ACF author field, you need to use Dynamic Data > PHP Function Return Value. Enter the function name my_get_user_field, and in the arguments box, enter the name of the ACF field that you want to retrieve.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.