Last active
January 20, 2016 20:48
-
-
Save rfmeier/7ec5e9283b2a333fcc71 to your computer and use it in GitHub Desktop.
Authenticate callback for WordPress register_meta() function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //* do not include php tag | |
/** | |
* Callback for WordPress register_meta() sanitize parameter. | |
* | |
* Determine if the current meta key and value should be visible within the | |
* WordPress post editor Custom Fields meta box. | |
* | |
* @see https://codex.wordpress.org/Function_Reference/register_meta | |
* | |
* @uses current_user_can() | |
* @see https://codex.wordpress.org/Function_Reference/current_user_can | |
* | |
* @param boolean $allowed True if allowed to view the meta field by default, false if else. | |
* @param string $meta_key The meta key. | |
* @param integer $post_ID The post ojbect ID. | |
* @param integer $user_id The user ID. | |
* @param string $cap The meta capability. | |
* @param array $caps An array of capabilities. | |
* @return boolean True if allowed to view the meta field by default, false if else. | |
*/ | |
function auth_sample_count_meta( $allowed, $meta_key, $post_ID, $user_id, $cap, $caps ) { | |
if ( ! current_user_can( 'edit_others_posts' ) ) { | |
$allowed = false; | |
} | |
return $allowed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment