Title: Massive application
Last modified: July 4, 2024

---

# Massive application

 *  Resolved [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/massive-application/)
 * I have a website with more than 300 pages that I want to protect.
   Is there any
   mass application system?If it does not exist, can you tell me some SQL code to
   do it through the db?Thank you!

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Support [Omar ElHawary](https://wordpress.org/support/users/omarelhawary/)
 * (@omarelhawary)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/massive-application/#post-17877606)
 * Hi [@elnoi](https://wordpress.org/support/users/elnoi/),
 * Thanks for reaching out Members Support Team!
 * We don’t have such an option like that in Members plugin.
 * Regards,
 *  Thread Starter [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/massive-application/#post-17877647)
 * Can you tell me some SQL code to do it through the database with phpMyAdmin?
 * Thank you!
    -  This reply was modified 1 year, 11 months ago by [elnoi](https://wordpress.org/support/users/elnoi/).
 *  Plugin Support [Omar ElHawary](https://wordpress.org/support/users/omarelhawary/)
 * (@omarelhawary)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/massive-application/#post-17878291)
 * The easiest way to add protection for multiple pages is to install [Code Snippets](https://wordpress.org/plugins/code-snippets/)
   plugin, add and adjust the code below and run it once (this plugin has special
   option to run code once without any hook):
 *     ```wp-block-code
       $pages = array(1297, 14); // The list of pages IDs that need to be protectedforeach($pages as $page) {	update_post_meta($page, '_members_access_role', 'administrator'); // Replace administrator to different role}
       ```
   
 * Regards,
 *  Thread Starter [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/massive-application/#post-17879323)
 * Thank you very much, I will try it and tell you
 *  Thread Starter [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17888969)
 * Hello Omar,
 * Until now I haven’t had time to try your solution.
 * I have already installed your code with Snippets and I have replaced ‘administrator’
   with a new role created, to activate it on all pages.
 * I have activated the code.
 * And nothing happens. I don’t know how to run it or where to run it from.
 * I would appreciate any help on this.
 * Thanks!
 * **Note:** Because I do not master the English language, I use Google Translate,
   both to write and to read, so I apologize if, for this reason, I have not understood
   your explanation well.
 *  Thread Starter [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17889792)
 * Sorry! I have already found how to execute a code with Code Snippets
   Still, it
   doesn’t work for me.Surely I do something wrong.I will continue experimentingThanks
   and sorry
 *  Thread Starter [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17890670)
 * It doesn’t work, I tried 10 times
 *  Plugin Support [Omar ElHawary](https://wordpress.org/support/users/omarelhawary/)
 * (@omarelhawary)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17890728)
 * Hi [@elnoi](https://wordpress.org/support/users/elnoi/),
 * Please share the code so I can check the issue from my end.
 * Regards,
 *  Thread Starter [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17890861)
 *     ```wp-block-code
       $pages = array(1297, 14); // The list of pages IDs that need to be protectedforeach($pages as $page) {update_post_meta($page, '_members_access_role', 'user_nivel_1'); // Replace administrator to different role}
       ```
   
 * Seeing that it didn’t work, I also tried it with a proposed code by IA ChatGPT
 *     ```wp-block-code
       function assign_roles_to_pages() {    // Llista d'IDs de les pàgines a protegir    $pages = array(1297, 14); // Afegeix aquí els IDs de les pàgines que vols protegir    // El rol que vols assignar (modifica'l segons necessitis)    $roles = array('user_nivel_1'); // Afegeix aquí els rols que vols assignar    foreach($pages as $page) {        // Comprova si la pàgina existeix        if (get_post($page)) {            // Obtenir els rols actuals            $current_roles = get_post_meta($page, '_members_access_role', true);            if (!is_array($current_roles)) {                $current_roles = array();            }            // Afegir els rols nous als existents            foreach ($roles as $role) {                if (!in_array($role, $current_roles)) {                    $current_roles[] = $role;                }            }            // Actualitza la metadada de la pàgina per assignar-li els rols            update_post_meta($page, '_members_access_role', $current_roles);        }    }}// Executa la funció una vegadaassign_roles_to_pages();
       ```
   
 * IA GPT has also proposed a solution using SQL
   (“If the code does not work, you
   can try fer-ho directly to the database with an SQL query.”)But at the moment
   I don’t dare to try
 *     ```wp-block-code
       UPDATE wp_postmetaSET meta_value = 'a:1:{s:13:"administrator";b:1;}'WHERE meta_key = '_members_access_role' AND post_id IN (1297, 14);
       ```
   
 * GPT points me to review the code to make sure the _members_access_role key is
   correct. But I don’t know how to do it.
   Anyway, I’m sorry for the inconvenience,
   but it would have to be something simpler, which I encourage you to implement
   in the plugin.
 * Regards
    -  This reply was modified 1 year, 10 months ago by [elnoi](https://wordpress.org/support/users/elnoi/).
 *  Plugin Support [Omar ElHawary](https://wordpress.org/support/users/omarelhawary/)
 * (@omarelhawary)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17892893)
 * [@elnoi](https://wordpress.org/support/users/elnoi/) I just tried to test code
   from my end it works. Please try to do SQL query but please make sure to back
   up database.
 * Regards,
 *  Thread Starter [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17893380)
 * It hasn’t worked for me either
   I’m probably doing something wrong, although I’ve
   tried everything.I have already wasted more time on proofs than perhaps what 
   it would have taken to point out the 300 pages one by one.In the end I will have
   no choice but to entertain myself by doing it manually.
 * I encourage you to implement this massive application option.
   If it existed, 
   in cases like mine, it is easier to apply it to all the pages and then manually
   modify the few that vary.
 * Maybe I’ll get by using a competitor’s plugin that does have a massive application
   system, even though I liked yours better.
 * Thank you for your patience and help even though it didn’t work in the end.
   Regards,
 *  Plugin Support [Omar ElHawary](https://wordpress.org/support/users/omarelhawary/)
 * (@omarelhawary)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17895305)
 * [@elnoi](https://wordpress.org/support/users/elnoi/) May I ask did you applied
   that on custom post type or pages?
 * Regards,
 *  Thread Starter [elnoi](https://wordpress.org/support/users/elnoi/)
 * (@elnoi)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17896441)
 * I do not understand very well your question.
 * In any case, as I explained from the beginning, the idea was to apply the visibility
   limitation, according to one or two user roles created, on many pages or posts
   at once.
 * But I thought this had already been clear from the first consultation contact.
 * I apologize if I have not expressed myself well or if the translation has not
   been adequate.
 * In any case, for some strange reason, perhaps because I haven’t been able to 
   explain myself well, none of the proposals have worked. I have tried them all.
 * Although it would be nice if this option were a little easier to do
 * I insist! I encourage you to implement this option in new versions, since there
   are other plugins, which do more or less the same as yours, and already have 
   this capability implemented. For some reason it will be
 * Thanks to the lack of working solutions, we can close the topic.
 * Regards,
 *  Plugin Support [Omar ElHawary](https://wordpress.org/support/users/omarelhawary/)
 * (@omarelhawary)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17904856)
 * I will address that to dev team so they can check your request.
 * Regards,

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Massive application’ is closed to new replies.

 * ![](https://ps.w.org/members/assets/icon-256x256.png?rev=3508404)
 * [Members - Membership & User Role Editor Plugin](https://wordpress.org/plugins/members/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/members/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/members/)
 * [Active Topics](https://wordpress.org/support/plugin/members/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/members/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/members/reviews/)

 * 14 replies
 * 2 participants
 * Last reply from: [Omar ElHawary](https://wordpress.org/support/users/omarelhawary/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/massive-application/#post-17904856)
 * Status: resolved