For your links issue, you could handle this easily with just a little extra php and a few more ACF fields.
Create a “Select field to your form, and give it the options that you’d like, such as URL, Page, Email, and File.
Next, you’ll create a text input for the URL, and at the bottom of the field options, select “Yes” for “Conditional Logic”. This will show a new section, and you can set this field to only show when the selected value of your drop down is equal to “URL” (it auto-populates the available choices for you).
Do the same thing when creating a “Page Link” relational field, “File” content field, and another text field for the email (you can set this text field up to validate the input to make sure it’s an email), and set their conditional logic appropriately.
Now when a user needs to add one of those to a page, they use the dropdown select field to select the type of link they’ll be adding, and the appropriate field will be shown to them. You could even do this inside of a repeated field so that they could add multiple links if that would work with your use-case.
In your theme files where you need to display these links, you would check to see if any selection was made, then get the data from the proper field based on which selection was made and build the link.
If you wanted to allow them to select a user, and get their email automatically for the field, you could use the “User” relational field type, and then in your template use the data returned to get the user’s email (I’m not sure offhand if this field returns an object or just the user id though, so you’d have to play around with it).
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 29, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.