WordPress.org

Ready to get started?Download WordPress

Forums

Profile page not visible for user with new role (2 posts)

  1. hansl
    Member
    Posted 2 years ago #

    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);
    		}
    	}
  2. timDesain
    Member
    Posted 2 years ago #

    check the capabilities each role using user-role-editor

Topic Closed

This topic has been closed to new replies.

About this Topic