You can use the acf/load_value filter https://www.advancedcustomfields.com/resources/acf-load_value/ to get the WP setting and return that.
There are very few examples of custom JS that I’m aware of. The only one I could find right now is https://support.advancedcustomfields.com/forums/topic/make-a-true-and-false-switch-flip-another/ which uses the acf.add_action function to add actions to fields.
I did some more digging and it seems that if “MY_OPTIONS” evaluates to a valid taxonomy name that your fields might be save incorrectly.
When ACF tries to figure out where it should be saving a blue it explodes the post ID resulting in
array(
'MY',
'OPTION',
'PAGE'
)
then it combines all but the last value of the array and looks to see if that is a valid taxonomy.
Anyway, I’d do a search of my database to see exactly where the values are being saved, if they are being saved at all.
As I said, it’s working for me. Have you tried removing other plugins or switching themes to see what might be interfering?
I was curious, so I created an options page using the following
$args = array(
'title' => 'MY_OPTIONS_PAGE',
'menu_title' => 'MY_OPTIONS_PAGE',
'menu_title' => 'MY_OPTIONS_PAGE',
'post_id' => 'MY_OPTIONS_PAGE'
);
Then I create a test field group with just a text field named “where_am_i”. I saved a value to it and then search the db for the value I save. It turned up in the options table with an option name of MY_OPTIONS_PAGE_where_am_i
. I also tried some other field examples including a repeater field and they all end up in the options table with the prefix of MY_OPTIONS_PAGE_
and everything worked as expected, although I’m not exactly sure how because for me this is unexpected behavior (but intriguing since this opens up things I was not aware of)
Anyway, this leads to the question of, if it does work, why isn’t it working for you.
The only answer that I can come up with here is that you have another field that also evaluates to the option name of MY_OPTIONS_PAGE_MY_REPEATER...
or that somehow your filter is interfering with the working of your have_rows() loop, though I can’t say why. When I run the code for the options in my page template on the site everything is working.
For your last example try something like
<?php
function set_acf_rgba_color_picker_palette() {
// optional - add colors which are not set in the options page
$palette = array(
'#FFF',
'#000'
);
// ====================================================================
// Try to the repeater as an array
// ====================================================================
$test = get_field('MY_REPEATER', 'MY_OPTIONS_PAGE');
echo "<pre>";
print_r($test);
echo "</pre>";
if ( have_rows('MY_REPEATER', 'MY_OPTIONS_PAGE') ) {
while( have_rows('MY_REPEATER', 'MY_OPTIONS_PAGE') ) { the_row();
$palette[] = get_sub_field('MY_COLOR_FIELD');
}
}
return $palette;
}
add_filter('acf/rgba_color_picker/palette', 'set_acf_rgba_color_picker_palette');
?>
https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/
See the append action. You and use this action to detect what field is being added and then add additional actions to the field.
Check out this tutorial about adding custom meta boxes to user profile pages. http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields. These custom meta boxes to not need to contain any actual fields and could just be html/text that shows additional information (skip the part about saving values).
the only requirement for the plugin is that the field names are the same
You code has me a bit confused
if ( have_rows('MY_REPEATER', 'MY_OPTIONS_PAGE') ) {
Are you trying to use the name or slug of the options page? If you are then this is incorrect. When getting values for options pages the $post_id value is always 'option'
or you can use 'options'
if ( have_rows('MY_REPEATER', 'option') ) {
the function wp_mail() can take an array or a comma separated list of emails to sent the email to https://developer.wordpress.org/reference/functions/wp_mail/.
You would need to get the users that you want to email. How you do that would depend on where and how they are set. If you’re using a user field the you’d need to get the users selected in that field and loop through them to get the list of email addresses.
how is $post_id
being assigned a value in your function?
As far as I know, the hook you’re working with is only run when an image is added to the tinymce editor. There would be no way to alter previously added image tags unless you delete them and then add them in again. To keep them up to date with some setting you’d need to filter “the_content” similar to the way WP filters the content images to make them responsive.
Yes, you could do that, but it shouldn’t be necessary.
Are you attempting to update a field that does not already have a value? If so the you should be using the field key in update field and not the field name. See the field key section of https://www.advancedcustomfields.com/resources/update_field/
function image_tag_class($class, $id, $align, $size) {
if (get_field( 'img_fullscreen', $id)) {
$class .= ' full';
}
return $class;
}
add_filter('get_image_tag_class', 'image_tag_class', 10, 4 );
I can’t give you details on every possible WP option, but generally you’re got 2 choices.
1) Use an acf/save_post filter when the options page is saved, take the values from the ACF fields and update the WP option value. Exactly how you’d do this update would likely be different depending on the option you’re overwriting. For example, the “Blog Title” field in the options table as “blogname”.
update_option('blogname', get_field('my_blog_name_field', 'options'), true);
2) The second option is to override the WP options in code. For example
add_filter('option_blogname', 'my_override_blog_name', 10, 2);
function my_override_blog_name($value, $option) {
$value = get_field('my_blog_name_field', 'options');
return $value;
}
Like I said, the above is only one example. You’d have to investigate how/where each of the options you want to override is saved and what can be done to override them. More than likely I would go with the first option of updating the actual WP options when the options page is saved. The reason for this is that 1) the DB locations of these options is not likely to ever change (while the filters for overriding them after the fact might) and 2) using the first method will work for the front end of the site even if ACF is deactivated.
All of the values saved by acf for posts are in the _postmeta table.
The license for a single site allows you to have automatic updates on a single site. It will run on both the dev/staging and production sites.
It might be possible, but I can’t say I will know all of what would be involved.
First off, you’d need to relate students to parents.
second you’d need to have a courses/classes post type that was is somehow related to teachers and students and these user fields could be restricted to a certain user role.
I misread your OP, it sounded to me like it was working the way it’s supposed to work.
I just did a test and can confirm that’s it is working correctly on my test site.
The validation is done using JavaScript and AJAX. Any error in JS or during the AJAX request can cause the request to fail and this might cause what you’re seeing.
The first step is to deactivate other plugins and possibly switch themes to narrow down what might be causing the conflict.
When you mark a field as required that is exactly what should happen, the field is required to have content or it will cause an error. If you want to be able to have fields with no value entered then they should not be marked as required.
ACF stores and array of ID values for user field and does the work of getting all the user information when you use get_field(). If you need to use get_post_meta() then you’ll need to do all that additional work yourself. See https://codex.wordpress.org/Function_Reference/get_userdata
You can use an acf/load_value filter https://www.advancedcustomfields.com/resources/acf-load_value/.
add_filter('acf/load_value/name=banner_image', 'override_banner_image', 10, 3);
function override_banner_image($value, $post_id, $field) {
if ($some_condition) {
// do conditionals and set value to a different attachment ID
}
return $value;
}
You’d still need to add to this function whenever you wanted to add more conditions to it.
ACF calls get_avatar() https://codex.wordpress.org/Function_Reference/get_avatar and this uses the default values, so the default size should be 96. This can be adjusted by adding a filter for pre_get_avatar https://developer.wordpress.org/reference/hooks/pre_get_avatar/
Values in the database, if you’ve renamed the fields, should not be conflicting with the new fields. I can’t say what the conflict is to be honest. It could be anything from some filter that’s been created to duplicated field names. The only way to clear out the old data for old field names is to delete them manually from the database.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.