Skip Navigation

[Waiting for user feedback] Problem with the configuration

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 8 replies, has 1 voice.

Last updated by Christopher Amirian 1 week, 4 days ago.

Assisted by: Christopher Amirian.

Author
Posts
#2816196
toolset-1.png
toolset-2.png
toolset-3.png
toolset-4.png

Hi, I am starting to use the access section. The website is multi-language with WPML. I need to create a user with restricted permissions that only has access to one language (I don't want that user to be able to access the other languages).
I have created a role and I have been configuring the permissions in Post types, taxonomies, post groups... and I have created a WPML Groups for the turkish language. I have also assigned this role to a user that I have created specifically for this.

I have 2 problems:
- When creating in WPML groups I don't get all the post types that appear in the post types tab where I have configured the permissions (for example I'm missing the post type events).

- I can't get the user in which I have done the tests to be able to see only one language (in this case Turkish).

I am testing in the test environment (I have registered it with the production environment).

test.xxxx

Thanks

#2816228

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support.

For the post type would you please make sure that the post type in question is translatable in WPML?

You can check that by going to WPML > Settings > Post Types Translation.

Select the left option for the Event post type to make sure it is translatable.

Also make sure that at least one event item is translated by WPML.

For the only language you can read this ticket:

https://toolset.com/forums/topic/wpml-allow-language-wise-access-to-specific-user/#post-2556845

Thanks.

#2817044

Hi,

I´m having some problems.

On the one hand, I have created a specific role, a user for that role and configured the translator but with that user I can still access the other languages that we have configured in WPML.

On the other hand, I don't see an option to make disappear from the backend some sections like comments, tools or some plugin that still appears even if the user doesn't have permissions for plugins.

#2817087

Christopher Amirian
Supporter

Languages: English (English )

Hi,

The user role that you create should be Editor, if you create a user role with the administrator role you will not be able to force the user.

Please check this documentation:

https://wpml.org/documentation/translating-your-contents/how-to-use-access-plugin-to-create-editors-for-specific-language/

Please also consider that the goal is to prevent the user to edit the other language content, but viewing the content will still be there.

To restrict a user to certain pages please follow the steps below:

https://toolset.com/lesson-placement/lesson-placements-1621543-1655635/

And for custom roles:

https://toolset.com/lesson-placement/lesson-placements-1621543-1622357/

Thanks.

#2817202

Hi,
I'll check it out but the custom role I created has very few permissions (even less than an editor).

Thanks

#2817219

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Please check with my reply, if you have issues please get back to us with login information by setting the next reply a private.

Also share the user that you created for the separate language.

And the user for limiting post types.

Thanks.

#2817909

Thanks, we've managed to create a user who can only edit and delete in the language we wanted. One last question: Is it also possible to only publish in the language we want? In the permissions section, we see that "Publish" doesn't offer the option to differentiate between "Own" and "Any" (and you can publish in other languages).

#2817927

Christopher Amirian
Supporter

Languages: English (English )

Hi,

As I am not sure about that I'd appreciate it if you could give the login information of the website by setting the next reply as private and give me the place to check that publish section so I can see myself.

Thanks.

#2818068

Christopher Amirian
Supporter

Languages: English (English )

Ok thanks. Now I understand what you require.

Toolset Access can separate Edit / Delete (own vs. any), but “Publish” is a single capability (publish_posts).
Access itself does not offer a per‑language switch for that capability, so a user who can publish in Turkish will also be able to press Publish when the post is assigned to English, Spanish, etc.

If you really need the user to keep the standard post editor and still press Publish, add a capability filter that checks the language of the post and stops the action unless it is Turkish.

/**
 * Prevent the "turkish_editor" role from publishing non‑Turkish posts.
 */
add_filter( 'user_has_cap', function( $allcaps, $caps, $args, $user ) {

    // we are mapping the `publish_post` capability
    if ( in_array( 'publish_post', (array) $caps, true ) ) {

        // only limit our custom role
        if ( in_array( 'turkish_editor', (array) $user->roles, true ) ) {

            $post_id = isset( $args[2] ) ? intval( $args[2] ) : 0;
            if ( $post_id ) {
                // get WPML language information for this post
                $info = apply_filters( 'wpml_post_language_details', null, $post_id );
                if ( $info && $info['language_code'] !== 'tr' ) {
                    // block publishing
                    $allcaps['publish_post'] = false;
                }
            }
        }
    }
    return $allcaps;
}, 10, 4 );

Replace turkish_editor with the slug of your custom role.

'tr' is WPML’s Turkish language code—change if needed.

Please consider that the code above is not part of Toolset and I did not test it. It is an attempt to help you achieve the feature you desire. But if it does not work you might need to hire a developer for that. For more information:
https://toolset.com/contractors/

Thanks.