Drupal Tricks - 1

BulkMail Verifier
Submitted by leopathu on Sun, 05/08/2022 - 13:01
drupal

I needed a way to check the currect user has permission to view the currect/particular page, Searched lot finally got the exact way, going to show the tricks to you in this blog.

Drupal has an api called " drupal_valid_path " , Normally it used to test the url is valid or not. but the trick is that, It also check the user has permission to view the currect/particular page.

It will return TRUE If path is valid and user has permission to view the page, otherwise it will return FALSE,

For example,

$path = current_path();

if (drupal_valid_path($path)) {  

    // Your code here.

}