Plugin Author
Chouby
(@chouby)
Hi!
This feature does not exist yet. I take note of your request to include it in our roadmap (We develop features based on the user requests).
Is there something changed in this issue? Polylang is very useful and friendly for users but without possible to restrict page modification/creation to a specific language for a specific user role, it’s seems uncompleted…
I don’t think there is any update on this matter yet.
I ended up coding it myself by adding hooks on save post. It’s not really clean but it makes the job for now…!
Can you explain how to do that? – I don’t know much about hooks…
Here is an example of code to add in your functions.php file.
It’s definetly not the cleanest code, as it exit the page a bit quick and without any good design, but at least it works..
function limitTraducteur( $post_id, $post, $update ) {
$usermeta = wp_get_current_user();
if (in_array("translator", $usermeta->roles) && isset($_POST) && count($_POST)>0) {
// If it's a menu, block the role to a specific ID menu
if (isset($_POST["menu"]) && $_POST["menu"]!=9) {
echo "Error: You are not allowed to edit this menu. Please select the German menu.";
echo "<br/><br/><a href='javascript:history.go(-1)'>Back</a>";
exit;
// For the other content than menu
} elseif ($_POST["post_lang_choice"]!="de" && $update==true && !isset($_POST["menu"]) && $_POST["menu"]!=9) {
echo "Error: You are not allowed to edit a content in a different language than German.";
echo "<br/><br/><a href='javascript:history.go(-1)'>Back</a>";
exit;
}
}
}
add_action( 'save_post', 'limitTraducteur', 10, 3 );
I’m doing something wrong but i don’t know what:
– I’ve created role ‘translator’;
– I’ve changed menu id and language code in function;
…and nothing happens… Maybe i missed something? Can you have a look on this code below? Thank you for your help.
function limitTraducteur( $post_id, $post, $update ) {
$usermeta = wp_get_current_user();
if (in_array("translator", $usermeta->roles) && isset($_POST) && count($_POST)>0) {
// If it's a menu, block the role to a specific ID menu
if (isset($_POST["menu"]) && $_POST["menu"]!=20) {
echo "Error: You are not allowed to edit this menu. Please select the Polish menu.";
echo "<br/><br/><a href='javascript:history.go(-1)'>Back</a>";
exit;
// For the other content than menu
} elseif ($_POST["post_lang_choice"]!="pl" && $update==true && !isset($_POST["menu"]) && $_POST["menu"]!=20) {
echo "Error: You are not allowed to edit a content in a different language than Polish.";
echo "<br/><br/><a href='javascript:history.go(-1)'>Back</a>";
exit;
}
}
}
add_action( 'save_post', 'limitTraducteur', 10, 3 );
-
This reply was modified 9 years, 3 months ago by
Kubzon.
-
This reply was modified 9 years, 3 months ago by
Kubzon.
Ok, my mistake durining upload file – but after seeing error message ‘You are not allowed…’, post is sill updated or published.
-
This reply was modified 9 years, 3 months ago by
Kubzon.