Skip to content

Instantly share code, notes, and snippets.

@robcolburn
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robcolburn/929322ace8086dd06a2a to your computer and use it in GitHub Desktop.
Save robcolburn/929322ace8086dd06a2a to your computer and use it in GitHub Desktop.
<?
/**
* Determine if user can access invoice.
* @param WP_Post $invoice
* The invoice to check.
* @return boolean
* TRUE if user can access invoice.
*/
function can_access_invoice ($invoice) {
global $current_user;
if ($current_user->can_edit("posts")) {
return TRUE;
}
$classifications = wp_get_metadata(…);
if (!empty($classifications) && in_array($classifications, $user->classification)) {
return TRUE;
}
$email = wp_get_metadata(…);
if (!empty($email) && $email == $current_user->email) {
return TRUE;
}
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment