User-edit role setting distinct from wp_capabilities? [closed]
User-edit role setting distinct from wp_capabilities? [closed]
User-edit role setting distinct from wp_capabilities? [closed]
The lack of mutiple roles has irritated me for a long time since the underlying WP_User class supports multiple roles. I have even considered looking for an alternative software solution. @lpryor – after reading your post, I was re-motivated to implement it myself. It took a surprisingly short number of lines to do although I … Read more
To accomplish user activation process you need to do following steps: after create new user add a custom user field which indicates that this user has to activate his account send an email with activation code, provide a link in this email to a page where user will be activated implement activation page when user … Read more
Don’t let the action die, just do a redirect (to wherever you’d like): function wpse_92155_before_delete_post() { wp_redirect(admin_url(‘edit.php’)); exit(); } // function wpse_92155_before_delete_post add_action(‘before_delete_post’, ‘wpse_92155_before_delete_post’, 1);
It didn’t say in the API docs on the Yoast SEO plugin site what the ID was and I don’t have a copy of Yoast at installed at disposal, but according to yoas-plugin-dir/admin/class-metabox.php line 144, the meta_box registered is; add_meta_box( ‘wpseo_meta’, …etc ); … Which is hooked onto add_meta_boxes hook on line 32 of the … Read more
It’s hard to troubleshoot the above code because it’s only a part of the actual code, but here’s the minimum plugin needed to register a custom post type (called Example) and a custom role (Blog Manager) that has access to the Example custom post type. This can be used as part of a theme’s functions.php … Read more
Here is the result that works, I put in the condition : is_product() to check if is a single product page. And I changed in the add_action() : admin_init by wp function cm_redirect_users_by_role() { $current_user = wp_get_current_user(); $role_name = $current_user->roles[0]; if ( is_product() ){ if ( $role_name !== ‘customer’ && $role_name !== ‘shop_manager’ && $role_name … Read more
The wp_capabilities saves the value as serilized array, you can try it in your php or for this example here: http://blog.tanist.co.uk/files/unserialize/. The Code: a:1:{s:13:”administrator”;b:1;} Is: Array ( [administrator] => 1 ) Meaning the user is an administrator. You can add new roles to the database by running the function add_role, and only run it once!
great answer, to take this a step further and for anyone looking to apply this to all non-admin users (e.g. contributers, editors etc.) // ===== remove edit profile link from admin bar and side menu and kill profile page if not an admin if( !current_user_can(‘activate_plugins’) ) { function mytheme_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu(‘edit-profile’, ‘user-actions’); } … Read more
Plugin It’s basically just a user capability check, followed by a redirect in an exit call. It then redirects to the site the request came from. <?php ! defined( ‘ABSPATH’ ) AND exit; /* Plugin Name: (#66093) »kaiser« Deny Admin-UI access for certain roles */ function wpse66093_no_admin_access() { // Do not run if the user … Read more