Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Paul

ACF WPML admincolumns synchronize with inline editing

I have synchronized all of my custom ACF fields through WPML so that the selections in my primary language will be reflected in the second language.

When i started testing i noticed that inline editing will not synchronize the change of a field in the second language when changed and updated on the primary language. If i go into the post and actually change it the normal way, it works and whatever is selected in the primary language shows the same in the secondary language.

This is a bit of a problem as I purchased admin columns specifically for this reason, to edit in the index view of the posts, rather than going in and editing each post.

Is this a known issue ????

4 years, 7 months ago
Stefan
Developer

WPML does the syncing for you when you save a post (save_post function) but this is not happing when using inline edit. Then only save_post_meta() is called. To have inline edit work with the WPML syncing feature, you’ll have to trigger the save_post action when an inline-dit save actions is called.

We have an action for this: cacinline-editafter_ajax_column_save documented here

Look at the first example. The function would be something like


function my_cac_update_post_for_wpml_on_save( $column, $id, $value, $editable_model_object ) {
	wp_update_post( array( 'ID' => $id ) );
}
add_action( 'cac/inline-edit/after_ajax_column_save', 'my_cac_update_post_for_wpml_on_save', 10, 4 );
4 years, 6 months ago
Nohemi

For those, like me, who come across this subject:
cac/inline-edit/after_ajax_column_save is deprecated. Replaced by acp/editing/saved.

function my_cac_update_post_for_wpml_on_save( $column, $id ) {
	wp_update_post( array( 'ID' => $id ) );
}
add_action( 'acp/editing/saved', 'my_cac_update_post_for_wpml_on_save', 10,2 );
2 years, 11 months ago
Calvin Yim

for those who have the exact problem, WPML have a method called wpml_sync_custom_field: https://wpml.org/wpml-hook/wpml_sync_custom_field/

wp_update_post will not do it, you can use the following codes

add_action ( 'acp/editing/saved', function ( AC\Column $column, $id, $value ) {
    if ( $column instanceof ACA\ACF\Column && $column->get_post_type() === 'custom_post_name') {
	do_action( 'wpml_sync_custom_field', $id, 'custom_field_name');
    }
}, 10, 3 );
7 months, 3 weeks ago
Calvin Yim

EDIT (Correction): after double check wp_update_post do work

add_action ( 'acp/editing/saved', function ( AC\Column $column, $id, $value ) {
    if ( $column instanceof ACA\ACF\Column && $column->get_post_type() === 'custom_post_name') {
    wp_update_post( [ 'ID' => $id ] );
    }
}, 10, 3 );
7 months, 3 weeks ago

You must be logged in to reply to this topic.