WordPress.org

Support

Support » Plugins and Hacks » Hacks » Profile page not visible for user with new role

Profile page not visible for user with new role

  • Hi,

    I’m trying to write my first plugin with users, roles and capabilities. I have added a couple of roles with subscriber capabilitie to the user admin part of wordpress. This works fine if I’m logged in as administrator, I can see the new roles and add the users. But when one of these new users with this new role is loggen in he can not access the profile page in the administrator or setting pages, like a subscriber normaly can do. If somebody can help me with this, that would be great!

    Code:

    register_activation_hook( __FILE__, 'abct_obuild_activate' );
    register_deactivation_hook( __FILE__, 'abct_obuild_deactivate' );
    
    function abct_obuild_activate() {
        if ( version_compare( get_bloginfo( 'version' ), '3.1', '<' ) ) {
            deactivate_plugins( basename( __FILE__ ) ); // Deactivate our plugin
        } else {
    		$role =& get_role( 'subscriber');
    		add_role('renter', 'Huurder', $role );
    		add_role('office_administrator', 'Kantoorbeheerder',array('read','edit_posts','delete_posts', 'upload_files', 'add_users', 'delete_users', 'edit_users'));
    	}
    }
    
    function abct_obuild_deactivate() {
    	$roles_to_delete = array(
    		'renter',
    		'office_administrator'
    	);
    	foreach( $roles_to_delete as $role ) {
    		/* Get the users of the role. */
    		$users = get_users( array( 'role' => $role ));
    		if ( count( $users ) <= 0 ) {
    			remove_role( $role);
    		}
    	}

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Profile page not visible for user with new role’ is closed to new replies.
Skip to toolbar