enter image description here

As you can see in the image, I have assigned student level 1 to a Page in WP admin. I am building a custom page.php on my own and I am trying to redirect the user back if they were not added.

I try with

if (!current_user_can('read_post'))

But obviously, all users and read a Page. What I am tryint to accomplish is somethinng like

current_user_is_in_content_permissions() ? display() : redirect_back();

How can write the code in my pages.php

WP automatically displays

Sorry, but you do not have permission to view this content.

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.