Create a Meta Box in the Admin User Screen?

Well, as you already know, meta boxes are for post types only… What you can do is to customize the heck out of that screen. What follows is the code I used on a client’s custom theme. Originally, it was used with the action hook admin_print_scripts-profile.php (which could also be added bellow). /functions.php: add_action( ‘admin_print_scripts-user-new.php’, … Read more

Restrict dashboard access for specific user roles to specific actions

This is how I ended up solving this issue. Originally I used this code for the link to delete an individual post: <?php if( !(get_post_status() == ‘trash’) ) : ?> <a class=”delete-post” onclick=”return confirm(‘Are you sure you wish to delete post: <?php echo get_the_title() ?>?’)”href=”https://wordpress.stackexchange.com/questions/78144/<?php echo get_delete_post_link( get_the_ID() ); ?>”>Delete</a> <?php endif; ?> After checking … Read more

Is it safe to post form data via Ajax to the settings api? Am I missing something?

WordPress does not natively use Ajax submits with Settings API, so there isn’t really best practice for it. I remember scbFramework having such option, but it was removed. Essentially there is nothing inherently more insecure to such submit, you should treat form data as untrusted regardless of submit method and appropriately sanitize and validate it … Read more

how to redirect to url.com/wp-admin if url.com/admin is typed in?

Hook into template_redirect, inspect the request URI, and redirect to the return value of admin_url(). add_action( ‘template_redirect’, function() { $request = untrailingslashit( strtolower( $_SERVER[‘REQUEST_URI’] ) ); if ( ‘admin’ === $request ) { wp_redirect( admin_url() ); exit; } }); Note: always use admin_url() and the other built-in URL functions, because they will take care of … Read more

Is there a way to have admins that are logged in to wordpress not have to enter the password for password protected pages while browsing the website?

Since 4.7 you can filter the post_password_required function: function my_admins_dont_need_password( $required ) { if ( current_user_can( ‘manage_options’ ) ) { $required = false; } return $required; } add_filter( ‘post_password_required’, ‘my_admins_dont_need_password’ ); Replace manage_options with whatever capability you want to use to allow users to skip the password form.

Adminstering Large Number of WordPress Sites

Well it depends on how/where they are hosted. If if they are hosted on different servers or the same I would still use the command line and a script file. If they all have different usernames/passwords you going to have to write a lot. Pre-planning will save you a ton of time in maintenance. First … Read more