Tag Info

New answers tagged

0

The translate_user_role function is just a wrapper for translate_with_gettext_context, defining the context 'User role'. In this last function, there is the filter hook gettext_with_context, which provides the context as well as the currently used domain. So we could do this: function wpdev_141551_translate_user_roles( $translations, $text, $context, ...


0

Have you looked at the Theme My Login plugin? It will do some of what you want, and you can customize it by writing a theme-my-login-custom.php file (assuming you know enough about PHP and Wordpress to do so).


1

So, thanks to kaiser, I was able to figure it out. I had to do two things to make this work. First, I noticed that disabling the WP User Avatar plugin was causing the errors to disappear. I looked and realized that a setting was checked "allow subscribers and contributors to edit their avatars." Unchecking it and saving it for each site made the errors ...


0

Here is an alternative way of doing it: /** * Get the blogs of a user where they have a given role. * * @param int $user_id The ID of the user. * @param string $role The slug of the role. * * @return object[] The blog details for each blog the user has the role for. */ function get_blogs_of_user_by_role( $user_id, $role ) { $blogs = ...


0

This one is much easier to add on the functions.php and works like charm : function hide_media_by_other($query) { global $pagenow; if( 'upload.php' != $pagenow || !$query->is_admin ){ return $query; } if( !current_user_can( 'manage_options' ) ) { global $user_ID; $query->set('author', $user_ID ); } return $query; } ...


1

The ability to set comment status is tied to the "edit_comment" capability, which is a meta-capability in WordPress. It maps to the "edit_post" capability, which is another meta-capability that varies depending on whether a post is published or not. In the end, if a post is published, then edit_comment ends up mapping to "edit_published_posts" for the ...


0

You can remove the capability from the role entirely. It you can replace the PUT_ROLE_HERE with your role: $edit_role = get_role(PUT_ROLE_HERE); $edit_role->remove_capability('moderate_comments'); As @SierraTR says, only Administrators and Editor have access to moderate comments, unless you have some kind of Role Plugin.


2

You could create a simple page template with just five lines of code: /* Template Name: Protected Page */ if ( ! is_user_logged_in() ) auth_redirect(); else require_once './page.php'; Then select that template for the page you want to protect. auth_redirect() will send the user to the login page and back to the original URL after they are logged ...


0

According to the Codex: Roles_and_Capabilities both the Admin and Editor roles have the capability of managing comments. At the bottom of that Codex page under Resources there are a few plugins listed for easily changing the capabilities of user roles ( other than Administrator ) and there are references to functions you can use to change the capabilities ...


0

This is an easy fix by simply using $_REQUEST instead of $_GET in your hidden field for register_form. More importantly, you should be sanitizing the field before you echo it, otherwise you're wide open to injection and CSRF: <?php if ( isset( $_REQUEST['role'] ) ) echo esc_attr( $_REQUEST['role'] ) ?>


3

admin_init runs on admin pages, not the front end. The equivalent front end action, init, is too early to check is_page. A safe action for redirection is template_redirect: function xyz() { if( is_page( 172 ) && ! current_user_can('update_core') ) { wp_redirect( home_url() ); exit; } } add_action( ...


2

You can use a filter to pre_get_posts so that only your posts are listed. Something like this: function my_posts_only( $query ) { global $pagenow; if ( 'edit.php' != $pagenow || ! $query->is_admin ) return $query; if ( ! current_user_can( 'manage_options' ) ) { global $user_ID; $query->set( 'author', $user_ID ); ...


0

The plugin contains for example these lines: add_menu_page('Newsletter', 'Newsletter', ($this->options['editor'] == 1) ? 'manage_categories' : 'manage_options', 'newsletter_main_index'); add_submenu_page('newsletter_main_index', $title, $title, ($newsletter->options['editor'] == 1) ? 'manage_categories' : ...


1

Yes this is possible. Add the following to either your plugin code or the theme's functions.php file: function mypo_parse_query_useronly( $wp_query ) { if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) { if ( !current_user_can( 'update_core' ) ) { global $current_user; $wp_query->set( ...



Top 50 recent answers are included