In this members-only tutorial, we shall register a custom function that returns the value of a user custom field created using the Advanced Custom Fields plugin which can then be used not only for displaying the currently logged-in user's custom field values but also for conditionally outputting any element using Oxygen's Dynamic Data condition depending on whether the field is empty or if it has a specific value etc.

Step 1

Let us first register a custom user field for users to have their Twitter handle.

Install and activate ACF or ACF Pro.

Go to Custom Fields > Add New.

Create your desired custom fields and set the field group to appear where User Form = All.

Registering an ACF user field group in WordPress

The new field will now appear when editing user profile pages and can be populated.

Populating ACF user field

Step 2

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: Return value of current logged-in user's custom field

Code:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

You need to be logged in to view and post comments.
Not a member yet? Join here.
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: