Publishers who can not create Administrators

I have long recommended the use of Members a fantastic plugin, to properly manage WordPress capabilities and roles, but there are times when it is not perfect, it has its nuances, I mean … [19659002] It is quite common to modify, once installed, some user profile (we are always talking about multiuser sites) so that, in turn, you can add other users. The idea is to build a collaborators structure in which someone, usually the Editor not only reviews the content created by users with profile of Contributor and Author but also can make " responsible for human resources " and add, modify and delete user profiles and their capabilities.

Well, with Members we can do all this but there is a catch and is that when we assign to a user profile the ability to create and / or modify users you can also create and / or modify users with Administrator profile, with the danger that this entails but check the table of Profiles and Capabilities of WordPress .

Fortunately, everything has a solution, so if this is your case (mine if it is, then I manage a network of blogs with multiple user profiles), you just have to acer esto:

  1. Instalas y activos Members
  2. Choose (or create) a user profile to which you will add the capabilities to create, modify, delete, change profiles and users


  3. Add this code to the file functions.php of your active topic:
     class JPB_User_Caps {
    
      // Add our filters
      function JPB_User_Caps () {
        add_filter ('editable_roles', array (& $ this, 'editable_roles'));
        add_filter ('map_meta_cap', array (& $ this, 'map_meta_cap'), 10.4);
      }
    
      // Remove 'Administrator' from the list of roles if the current user is not an admin
      function editable_roles ($ roles) {
        if (isset ($ roles ['administrator']) &&! current_user_can ('administrator')) {
          unset ($ roles ['administrator']);
        }
        return $ roles;
      }
    
      // If someone is trying to edit or delete and that user is not an admin, do not allow it
      function map_meta_cap ($ caps, $ cap, $ user_id, $ args) {
    
        switch ($ cap) {
            case 'edit_user':
            case 'remove_user':
            case 'promote_user':
                if (isset ($ args [0]) && $ args [0] == $ user_id)
                    break;
                elseif (! isset ($ args [0]))
                    $ caps [] = 'do_not_allow';
                $ other = new WP_User (absint ($ args [0]));
                if ($ other-> has_cap ('administrator')) {
                    if (! current_user_can ('administrator')) {
                        $ caps [] = 'do_not_allow';
                    }
                }
                break;
            case 'delete_user':
            case 'delete_users':
                if (! isset ($ args [0]))
                    break;
                $ other = new WP_User (absint ($ args [0]));
                if ($ other-> has_cap ('administrator')) {
                    if (! current_user_can ('administrator')) {
                        $ caps [] = 'do_not_allow';
                    }
                }
                break;
            default:
                break;
        }
        return $ caps;
      }
    
    }
    
    $ jpb_user_caps = new JPB_User_Caps (); 
  4. You save the changes and You're done! now the new user profile will be able to create and modify profiles but you will not be able to create administrators or modify their profiles to not to be, in turn, administrator

Enjoy it!

What you read is an original content of Help WordPress – Resources, themes, plugins and tutorials in Spanish and published it Fernando Tellado first here: Editors who can not create Administrators

"more" that break the template • WordPress Help

A curious thing happened to us recently in the blog network and that I share in case it ever happens to you, it's something I did not know could happen.

It turns out that suddenly the template of one of the blogs appeared unconfigured with the sidebar under the main content. Checking the theme code, still sure that we had not made any changes, there was no open tag or anything strange, so I went to the second step when there are problems: reviewing the code inserted in the posts.

And the only thing I found was that the tags 'more' were wrapped in 'divs' a very strange question, and that it had no logic unless the editor had used a desktop manager to insert them automatically and I would not have noticed, for example.

So you know, the 'more' alone, without company.

Between Blogs grows and seduces • WordPress Help

A new blogger has just joined the network Entre Blogs . True Seduction joins Between Blogs with what we already offer 12 visions of the blogosphere, with original quality content and veteran bloggers that offer us their particular vision of what they know best and share.

In True Seduction you can find courses and seminars on seduction and personal development relationships of couples and self-help . A very interesting blog if you are looking for help to gain confidence .