John Huebner
Forum Replies Created
-
Forum: Plugins
In reply to: [Visibility Logic for Elementor] Site Caching QuestionAfter further investigation. I was just looking at the plugin and this plugin depends on the
elementor/frontend/section/should_renderhook. My understanding of this hook is that it completely removes the content from the page rendering on the PHP side. To my understanding this means that the page would be cached based on the visitor viewing the page when it was cached.Please correct me if I am wrong.
Forum: Plugins
In reply to: [ACF Post-2-Post] 1:N Relationship not Working as ExpectedThis is working as expected.
There is no mechanism in ACF to give a “warning” or “message” that the field on the other end will not be updated without returning an error for the field that will prevent the post from being saved. Let me know if you need me to expand on this.
Preventing a post from being saved is not something that I would want to do because there would be people on the other side of the coin that would not want this. I have made the decision to ignore the update if it breaks the rules on the other end of the relationship and leave it up to the individual developer to alter this to allow overwriting the value on the other end.
Something like this is left up do the developer using this plugin. Using the acf/validate_value filter provided by ACF this can be accomplished.
For example:
// this code has not been tested add_filter('acf/validate_value/type=post_object', 'validate_bidirectional_relationships', 20, 4); add_filter('acf/validate_value/type=relationship', 'validate_bidirectional_relationships', 20, 4); function validate_bidirectional_relationships($valid, $value, $field, $input) { global $post; if (!$valid || empty($value)) { return $valid; } $posts_ids = $value; if (!is_array($posts_ids)) { $posts_ids = array($posts_ids); } $messages = array(); foreach ($posts_ids as $post_id) { $remote_value = get_field($field['name'], $post_id); if (empty($remote_value)) { continue; } if (!is_array($remote_value)) { $remote_value = array($remote_value); } $max_posts = 0; $remote_field_object = get_field_object($field['name'], $post_id); if ($remote_field_object['type'] == 'post_object') { if (!$remote_field_object['multiple']) { $max_posts = 1; } } elseif ($remote_field_object['type'] == 'relationship') { if ($remote_field_object['max']) { $max_posts = $remote_field_object['max']; } } if ($max_posts > 0 && count($remote_value) == $max_posts && !in_array($post->ID, $remote_value)) { $remote_post = get_post($post_id); $messages[] = $remote_post->post_title.' cannot be selected'; } } // end foreach if (!empty($messages)) { $valid = implode('<br />', $messages); } return $valid; } // end functionThere is also no mechanism in ACF to disable (“gray out”) a value in a select2 field so that it is not selectable. The only thing that could possibly be done here is to use an acf/fields/relationship/query or acf/fields/post_object/query filter to filter out posts that cannot be selected by adding a “post__not_in ” argument. Similar but more complicated than the above filter. However, such a filter would likely be detrimental to performance because you’d need to look at the value of every possible post that could be selected to determine if selection would mean the other post would have too many. In all likely hood this would time out the AJAX request and just break the field.
- This reply was modified 4 years, 4 months ago by John Huebner.
Forum: Plugins
In reply to: [ACF Post-2-Post] Bi-directional Relationship & Quick EditWhen you say that you are using quick edit, is this only to change a post from draft to publish or are you somehow editing the relationship field in quick edit.
If you are just publishing the post, I tested this and it works as expected.
If you are trying to edit the relationship field in quick edit somehow, this plugin does not have the ability to update the relationship on the other end unless whatever you’re using calls the acf function update_field(), to update the relationship value. This plugin depends on the acf/update_value hook being triggered.
Forum: Plugins
In reply to: [Activity Log - Monitor & Record User Changes] Extend Activity Log?Forum: Plugins
In reply to: [ACF Post-2-Post] Relationship not workingalso, what code are you using to display these relationships on the front end?
If the correct posts appear in the relationshipd fields in the admins of all posts then this is all that this plugin does.
There shouldn’t be any reason except for those I’ve noted that it should not work.
There is another condition that could cause this.
If you have both sites of the relationship open in the admin and you attempt to updated them both then they will be updated with the current values in the fields. If Post A is saved with a relationship to post B then you much reload post B in the admin to see that relationship. Updating without doing this will cause the relatiohsip to post A to be removed.
Forum: Plugins
In reply to: [ACF Post-2-Post] Relationship not workingDo the fields on both post type have identical field names?
Forum: Plugins
In reply to: [ACF Post-2-Post] Relationship not workingAre you using a relationship fields or post object fields?
If it’s a relationship field what is there a max number of posts set for it?
If it’s a post object field is “Select Multiple Values” set to “Yes”
This plugin will only create relationships up to the maximum allowed by the field’s settings.
Forum: Plugins
In reply to: [Classic Editor +] Error Updating to 2.6.4That corrected the issue for me.
Forum: Plugins
In reply to: [Classic Editor +] Error Updating to 2.6.4Just did a test on another site that is not multisite. Everything is working fine. Must be something in the difference between how permissions are checked on multisite and the fact that only super admin can install plugins. The exact issue still eludes me. Something that is not set up to deal with multisite in the dependency installer.
Forum: Plugins
In reply to: [Classic Editor +] Error Updating to 2.6.4Really confusing since I can’t find any reference to either of these constants in this plugin.
Forum: Plugins
In reply to: [ACF User Role Field Setting] Remove the author from the list of rolesThere isn’t a way to remove them.
Honestly, you should not use this plugin, it does not work in all cases. Most people need options like this rarely and only for a couple of fields. It is better to do this yourself using an acf/prepeare_field filter for only the fields you want to restrict or to put the fields into their own field group and use location rules to limit who can edit the fields.
Forum: Plugins
In reply to: [ACF Post-2-Post] Bi-directional relationship not workingThis plugin will not cause errors when deactivated.
Forum: Plugins
In reply to: [ACF Post-2-Post] Bi-directional relationship not workingI’m not sure what you are asking, but I am guessing.
This plugin cannot be used retroactively and it does not have the ability to update bidirectional relationship fields that already have values.
To get the fields to update you will have to manually update the posts on one side of each relationship.
Forum: Plugins
In reply to: [ACF Post-2-Post] Reciprocal relationship on Same CPT?This is correct and I do not know if what you want to do is possible. You might be able to use an acf/prepare_field filter to alter the label of the field if you can detect a difference in the post.
This plugin has a very simple use case. For your case I would likely use to fields and custom code the bidirectionality
Forum: Plugins
In reply to: [ACF Post-2-Post] Reciprocal relationship on Same CPT?A single field on one post type is automatically bidirectional when this plugin is active because the field exists for all posts on the post type.