After adding add_role to functions.php and creating a user, can not login into admin

That’s because the “normal” capabilites that are needed to login are missing. You should simply load the capabilites of some default role and attach them to your custom role before using it on a user. EDIT: Solution from @dashalune (OP): add_role(‘resourcerer’, ‘Resourcerer’); $role =& get_role(‘resourcerer’); $role->add_cap(‘read’);

How to write a plugin to add users to a mail list

You would hook into profile_update and user_register. First check to see if it’s a new user and whether she is an admin/editor. Then send the mail. Same story with updating the user: see if the role has changed, and whether the new role is admin or editor. <?php add_action( ‘profile_update’, ‘wpse33949_profile_update’ ); add_action( ‘user_register’, ‘wpse33949_profile_update’ … Read more

Prevent Editors from Editing/Deleting Admin Accounts

There is a function WordPress uses called get_editable_roles, which is (I think) used to determine which roles a particular user can edit. The source for this function looks like this: function get_editable_roles() { global $wp_roles; $all_roles = $wp_roles->roles; $editable_roles = apply_filters(‘editable_roles’, $all_roles); return $editable_roles; } So, it looks like you may be able hook into … Read more

Contributor disable seeing others’ posts

I hope you are talking about wp-admin section. If yes just place this code in your functions.php file add_action( ‘load-edit.php’, ‘posts_for_current_contributor’ ); function posts_for_current_contributor() { global $user_ID; if ( current_user_can( ‘contributor’ ) ) { if ( ! isset( $_GET[‘author’] ) ) { wp_redirect( add_query_arg( ‘author’, $user_ID ) ); exit; } } }

Add user settings to specific roles

On the profile page exists a global variable $profileuser. The member $profileuser->roles is an array of all roles for that user. <?php # -*- coding: utf-8 -*- // Plugin Name: personal_options add_action( ‘personal_options’, ‘print_user_roles’); function print_user_roles() { global $profileuser; print ‘<pre>$profileuser->roles=” . htmlspecialchars( var_export( $profileuser->roles, TRUE ), ENT_QUOTES, “utf-8’, FALSE ) . ‘</pre>’; } Output: … Read more

How to redirect specific post type with user role

add_action(‘load-index.php’, ‘redirect_dashboard’); function redirect_dashboard() { if ( ! is_admin() || current_user_can(‘activate_plugins’) ) return; $screen = get_current_screen(); if ( is_object($screen) && $screen->base == ‘dashboard’ ) { $url = admin_url(‘edit.php’); wp_safe_redirect( add_query_arg( array(‘post_type’ => ‘product’), $url) ); die(); } }

Display posts from multiple user roles

// Query user data on admins $administrators = new WP_User_Query( array( ‘role’ => ‘administrator’ ) ); // Query user data on contributors $contributors = new WP_User_Query( array( ‘role’ => ‘contributor’ ) ); // Save admin IDs foreach( $administrators->results as $u ) $user_ids[] = $u->ID; // Save contributor IDs foreach( $contributors->results as $u ) $user_ids[] = … Read more

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