Ok. For the moment I fixed the first point using this code:
/**
* Get the _members_access_role meta key for translated pages, to make Members plugin access controll work
*/
function sync_members_access_role_meta_field($meta_value, $object_id, $meta_key, $single) {
// Check if the meta key is '_members_access_role'
if ($meta_key === '_members_access_role') {
// Use a static variable to prevent infinite loop
static $is_running = false;
if ($is_running) {
return $meta_value;
}
$is_running = true;
// Get the current language
$current_language = apply_filters('wpml_current_language', null);
// Get the default language
$default_language = apply_filters('wpml_default_language', null);
// If the current language is not the default language
if ($current_language !== $default_language) {
// Get the original post ID
$original_post_id = apply_filters('wpml_object_id', $object_id, get_post_type($object_id), true, $default_language);
// Get all values of the custom meta field from the original post
$meta_values = get_post_meta($original_post_id, $meta_key, false);
// Reset the static variable
$is_running = false;
// Return all meta values if not requesting a single value
if (!$single) {
return $meta_values;
}
// Return the first meta value if requesting a single value
if (!empty($meta_values)) {
return $meta_values[0];
}
return '';
}
// Reset the static variable
$is_running = false;
}
return $meta_value;
}
add_filter('get_post_metadata', 'sync_members_access_role_meta_field', 10, 4);
-
This reply was modified 3 months ago by
toondg.