Thanks, more hooks into ACF so that we could modify the default interface would relieve a lot of work for him…
I have filters that set READ-ONLY and handle shortcodes, but I have to write code every time I want to do it. I’d rather I could just set it in the interface, which is why I want to modify the interface.
I have stuff I want to release to other stations our company owns and they don’t have programmers.
And I am completely baffled as to why this has NEVER been implemented, even though I’ve found dozens of requests for it.
There’s not an array I can parse or something?
Basically I want to add an option to all fields for “READ-ONLY” and an option to process shortcodes for the default.
Ugh, I was doing it wrong.
Thanks!
Thanks James, I created a ticket.
That works. However, here’s my biggest issue…
I am using ACF like crazy to create tons of extensions to our web site. And having the code separate from the “form” makes it difficult to maintain.
The ability to attach the code for a given field to that field in the ACF builder would now only allow me to more easily maintain the code whenever I make changes, but it would allow me to export/import the associated code with each form.
Maybe this is better off as an addon, but I would really love to see the ability to add JS and PHP code to each field in the ACF form builder.
Sorry, been been extremely busy at work.
This is probably more for an ACF addon that a feature, but in order to add code associated with any ACF field, you have to add it to FUNCTIONS.PHP or a custom plugin.
I’d really love to see an additional section for each field that allows me to plug my code right into each individual field’s settings.
So, I can stick some JS code that handles validation or loading data from an external source, or updating other fields in the metabox.
For example, I have an ACF form for handling basketball brackets. And I’d like to display an update to the bracket in an HTML field each time a game is added. Right now, you have to add the game, update, then view the bracket on a front end page. Very time consuming.
It would also be nice to attach PHP code to a field that is executed each time the field is updated. Again, I can write code in my custom plugin, but maintaining it all gets to be a hassle when it would be so much easier if it were right there as an added section for each field.
Okay… So I’m an idiot… The code actually works, but I did not specify HOW MANY posts I wanted, so WordPress just kept giving me 5, which just happens to be the number of games.
Adding 'posts_per_page' => -1
fixed my problem.
Okay, I simplified it to just:
'meta_query' => array( 'relation' => 'OR',
array( 'key' => 'game_home_team', 'value' => $team_id ),
array( 'key' => 'game_away_team', 'value' => $team_id )
)
Ignoring the sport and season. And I am still only getting home or away games depending on the order of the keys.
One way might be using filters. Perhaps he can create hooks that I can use to set where the file goes and if it gets added to the gallery.
I would like to suggest the following public functions for developers:
acf_prepare_form( formId )
All it does is add the appropriate JS setup code/links to the header or footer so that forms can be rendered.
acf_render_form( formId )
All it does is render the form and any necessary JS code for validations, etc…
acf_process_form( formId )
All it does is process the form data and does not output any HTML, just error codes if there is an error.
Of course, they may already exist, I’ll have to dig through the code and see how forms work in ACF.
Thanks Elliot. Maybe an easy short code [acf_render_map id="div-id-of-map-container" mapid="acf-field-name"]
Thanks, I’ll try the Message Field thing with the filter and see how that works.
I can post this in a separate thread, but it sure would be nice to attach PHP code to a form to keep things nice and neat together.
@augusto
Yes, my users need to see the data in the field and I need them to NOT change it in any way.
However, I don’t allow users to access the back end of the site, so I was able to create a form on the front end for adding/editing data and add the additional “read-only” fields in that front end form.
The addition of a READ ONLY option for every field type is still a critical need, in my opinion. I’ve been playing with other plugins like ACF and it appears to be the only one that doesn’t support a READ ONLY option.
There is another plugin which does it by saving the current zoom, the current center and all marker positions (it allows for more than one marker).
I would be happy if you saved just the marker position, the current center position and the zoom. With those 3 items, I could create the map on the front end that looks like it does on the back end.
Also, can you specify which form you want via an ID or slug? And can you create new posts? It appears from what I’m seeing in the docs that the acf_form functionality only edits the metadata for the post/page it’s displayed on.
Well, for my specific purpose, I can include a method for setting a “flag” to call acf_form_head()
. However, I was kind of hoping I could create a “generic” plugin that allowed ACF users to include forms on pages using a shortcode.
Is there anything in acf_form_head()
that requires being called before the page is rendered? Because the JavaScript can be loaded in the footer.
Optimally, I’d want to call acf_form_head()
only when the shortcode is present, but how much overhead is there if I wanted to just add it to every page/post on the front end?
No, when you select “Taxonomy” as the field type, there should be an option to “hide associated metabox”.
So, if I add the custom taxonomy “purple-flurp” to my form, there would be a checkbox in the field options for “Hide associated taxonomy metabox”. If checked, then the metabox I added to my form would not be shown in the edit sidebar.
Correction:
/* Remove Custom Taxonomy Meta Boxes */
function dads_remove_tax_meta() {
remove_meta_box( 'ad-zonesdiv', 'digital-ads', 'side' );
}
add_action( 'add_meta_boxes' , 'dads_remove_tax_meta' );
“add_meta_boxes” is the better action to capture and post removes it from all post types while I can specify the post type directly.
Found it!
/* Remove Custom Taxonomy Meta Boxes */
function dads_remove_tax_meta() {
remove_meta_box( 'ad-zonesdiv', 'post', 'side' );
}
add_action( 'admin_menu' , 'dads_remove_tax_meta' );
Okay thanks. I was really wondering what the best practice was, but I guess I should just install ACF on my dev site and play with scenarios.
Thanks!
If a site already has ACF installed and I include ACF:Pro in my plugin, will the end user have access to the Pro features? How do I handle that?
Is there an answer?
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.