Hide top admin panel for non admin and non editors

This is what i am using; add_action(‘init’, ‘blockusers_init’); function blockusers_init() { if (is_admin() && !current_user_can(‘administrator’) && !(defined(‘DOING_AJAX’) && DOING_AJAX)) { wp_redirect(home_url()); exit; } } It’s possible the best one. EDIT : You need a custom login page for reach wp-admin. This code redirect to homepage if you enter directly to wp-admin.

Echo custom admin field into a is_single()

$postids = get_option(‘codeable_posts_field’); This will give you a string of comma separated post ids (according to your code, and if the user follows the instructions). array( $postids ) will turn it into an array with that string as the only element. That won’t work with is_single(), obviously, because is_single doesn’t do any further splitting. Here’s … Read more

Where to store publicly-accessible files

I think that would depend how you’ve made your site private? I’ve used this plugin to set sites to private https://wordpress.org/plugins/jonradio-private-site/ It also has settings to exclude any URLs from being set to private. There are a bunch of other plugins that do similar thins.

Comments counter only for Authors Posts

For the moment just for hiding the comments counter from an author role, i made a small code like that /* * Hide Comments Counter for Author Hook */ if ( ! current_user_can( ‘manage_options’ ) ) { add_filter( ‘comment_status_links’, function( $status_links ) { // Override the original links: $status_links[‘trash’] = sprintf( “<a href=%s>%s <span class=”count”></span></a>”, … Read more

Sort columns in the ‘Pages’ dashboard overview

I just realized that there was a typo in the code. The meta-tag should read ‘prod_hierar’ instead of ‘prod-hier’. This fixes the issue. (Too much experimenting, I guess ..). Function ‘wms_hierarchy_col_orderby()‘ thus becomes: function wms_hierarchy_col_orderby( $vars ) { if ( isset( $vars[‘orderby’] ) && ‘prod_hierar’ == $vars[‘orderby’] ) { $vars = array_merge( $vars, array( ‘meta_key’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)