Change WordPress user roles and capabilities Forums How to or FAQ How to change permission for multiple pages at once

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #4582

    Good day.

    I am looking for solution, how to change permission for multiple pages at once.

    I have multiple pages(50+) which can be accesed/read only by “LEVEL2” user role and I want all these pages be accesed also by “LEVEL1” users. Is it possible to do that on “one” click? Not to go throuh all the pages.



    It’s not possible inside URE Pro. You have to use PHP code to make this update. Like this:

    add_action('admin_init', 'ure_content_view_add_role');
    function ure_content_view_add_role() {
        global $wpdb;
        $key = URE_Content_View_Restrictions::content_for_roles;
        $query = "SELECT meta_id
                    FROM {$wpdb->postmeta}
                    WHERE meta_key='{$key}' AND meta_value='level1'";
        $list = $wpdb->get_col($query);
        if (empty($list)) {
        foreach ($list as $meta_id) {
            $query = "UPDATE {$wpdb->postmeta} SET meta_value='level1, level2' WHERE meta_id={$meta_id} LIMIT 1";

    This code takes all posts and pages for which content view access roles set to ‘level1’ and replaces ‘level1’ with the list of roles: ‘level1, level2’.

    1. Create a fresh database backup
    2. Place this code as a separate .php file into wp-content/mu-plugin/ folder as a Must Use plugin.
    3. Open any page under yoursite/wp-admin
    4. Remove this .php file from wp-content/mu-plugin/ folder.
    5. Check the results.

    Code will be more complex if you need to make changes for the pages only and do not touch any posts which can have the same role in view permissions.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.