bulk change/remove content permissions

5 Replies ·

  1. I have a many (hundreds) of custom posts that have content permissions set to limit access to roles Administor and MyRole. I no longer need to limit access to these posts. Can you suggest a simple way to remove the access control on all of these posts?

  2. Justin Tadlock

    Currently, there’s no bulk remove option. However, there is the members_delete_post_roles() function, which will delete all the roles stored for an individual post. So, it’s possible to do this via code if you have all of the post IDs like so:

    $post_ids = array(
    foreach ( $post_ids as $post_id ) {
        members_delete_post_roles( $post_id );

    If you wanted to delete all the roles for all the posts, we could do that without having to know the IDs. Or, if they were all in a specific category or tag, for example, I could write up a query for that. Or, if there’s some other way those posts can be differentiated from posts that you don’t want to remove the roles from (e.g., posts from a specific author), we could probably work with that.

  3. hauser

    Thanks for your help. Yes, I want to delete all roles from custom posts of type “presentation” with custom taxonomy type “presentationyear” value of “2014”, “2015”, or “2016”.

  4. Justin Tadlock

    Running this code once should do it. I’d recommend running a testing environment first to make sure it works how you want.

    $loop = new WP_Query( [
        'post_type' => 'presentation',
        'tax_query' => [
                'taxonomy' => 'presentationyear',
                'field'    => 'slug',
                'terms'    => [ '2014', '2015', '2016' ]
    ] );
    while ( $loop->have_posts() ) {
        members_delete_post_roles( get_the_ID() );
  5. hauser

    This worked fine after I reset posts per page in the query with 'posts_per_page' => -1,