0

I created a new role: 'student' and student capabilities are as follows:

add_role(
            'student',
            __( 'Student' ),
            array(
                   'read' => true,  // true allows this capability

               )
        ); 

I wanted to give all student to read a custom post type: 'Assignment'. But when I login as student I can't see any menu item named: Assignment. But when I login as 'teacher' I can see this 'assignment' menu. Here is the 'teacher' role capability:

  add_role(
            'teacher',
            __( 'Teacher' ),
            array(
                'read'         => true,  // true allows this capability
                'edit_posts'   => true,
                'delete_posts' => false, // Use false to explicitly deny
            )
        );

Why student can't see assignment menu. What's wrong with my code?

  • 'read' => true allows you to access the Dashboard and the Profile. No other stuff if not explicitly stated. – Max Yudin Dec 9 '17 at 12:57
  • So, What should I do for my requirements? – Abdus Sattar Bhuiyan Dec 9 '17 at 13:44
  • I am not sure why do you need 'Student' and 'Teacher' roles when 'Subscriber' and 'Contributor' already has the same capabilities. In case you want them to have access only to a custom post type, you have to create capabilities instead of using the defaults, for example, read_assignment, edit_assignment, edit_assignments, edit_others_assignments and so on. – Max Yudin Dec 9 '17 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.