How can i add custom field validation to this code? if musteri_danismani
field is equal to current user, user can edit post. (musteri_danismani is a custom field.)
function author_can_edit_post(){
$role = get_role( 'author' );
$user = wp_get_current_user();
$userid = $user->ID;
if ( $musteri_danismani == $userid ){
$role->add_cap( 'edit_others_posts' );
}
else {
$role->remove_cap( 'edit_others_posts' );
}
}
add_action( 'init', 'author_can_edit_post' );
Anyone can help me ?