Home › Forums › Backend Issues (wp-admin) › acf_render_field_setting() position in form
I need the ability to set READ_ONLY based on user roles/capabilities.
I have the code working just fine. However, my field is rendered in the field options form just after the “required” button. And I want it rendered farther down the form (preferably before “Conditional Logic”).
I tried changing the priority for my add_action() call, but that doesn’t seem to affect things.
I am “guessing” that general/generic “acf/render_field_settings” actions are rendered before all of the individual field types are rendered. So the only way to get my item farther down the form is to create an add_action() for every single field type instead of using the “acf/render_field_settings” action.
Yes, this is true. The generic acf/render_field_settings hook is only fired at the beginning. I know that the developer at least knows about this because I’ve brought it up on github, but I do not know the status of this. I’ve worked out my own solution. I would suggest opening a support ticket https://support.advancedcustomfields.com/new-ticket/
I solve it by adding the action to every field type for now…. and this is also a little dependent on the version of ACF, 5.5.* stored the fields a bit differently. this is the relevant code from one of my plugins.
$function = 'name of function to call';
$priority = 1; // change to 20 for bottom of settings
$acf_version = acf_get_setting('version');
$sections = acf_get_field_types();
if (version_compare($acf_version, '5.5.0', '<') ||
version_compare($acf_version, '5.6.0', '>=')) {
foreach ($sections as $section) {
foreach ($section as $type => $label) {
add_action('acf/render_field_settings/type='.$type, $function, $priority);
}
}
} else {
// >= 5.5.0 || < 5.6.0
foreach ($sections as $type => $settings) {
add_action('acf/render_field_settings/type='.$type, , $function, $priority);
}
}
EDIT: You’ll want to do this on ‘acf/init’ or on ‘init’ with a high priority
The topic ‘acf_render_field_setting() position in form’ is closed to new replies.
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.