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.
Since writing this tutorial, one of my friends has released a snippet plugin called WPCodeBox. It has cloud-based snippet storage, and is now my snippet plugin of choice.
Once you've installed the scripts plugin of your choice, you can create a new snippet with the following code:
function my_get_user_field($field) {
$author_id = get_the_author_meta( 'ID' );
$user = "user_" . $author_id;
$acf_info = get_field($field, $user);
return $acf_info;
}
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.
You can see an example of how to do this here:
You should then see your ACF data shown in your Oxygen template.
"*" indicates required fields