Skip to content

Instantly share code, notes, and snippets.

@BERRAMOU
Created April 30, 2020 20:05
Show Gist options
  • Save BERRAMOU/813633c7af9e4a4789f728e94d2ebb4e to your computer and use it in GitHub Desktop.
Save BERRAMOU/813633c7af9e4a4789f728e94d2ebb4e to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_menu().
*/
function MODULENAME_menu() {
$items = [];
$items['api/v1/sample/request'] = [
'page callback' => 'sample_request',
'access callback' => 'user_is_api_user',
'type' => MENU_CALLBACK,
];
return $items;
}
function user_is_api_user() {
global $user;
return (bool) ($user->name == 'api');
}
@BERRAMOU
Copy link
Author

The result for users with name different of api
Screenshot 2020-04-30 at 22 07 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment