Publisher is the useful and powerful WordPress Newspaper , Magazine and Blog theme with great attention to details, incredible features...

[diario_shortcode template=”card_img” colunas=”4″ s=”internofolha” numero_de_parceiros=”4″ mono_post=”sim” colunas=”4″ top=”4″]

Como exibir conteúdo apenas para usuários logado wordpress

Código que exibi apenas conteúdo postado por seus respectivos autores

add_action( ‘load-edit.php’, ‘wpmidia_posts_for_current_author’ );add_action( ‘load-edit.php’, ‘wpmidia_posts_for_current_author’ );function wpmidia_posts_for_current_author() { global $user_ID;
if ( ! isset( $_GET[‘author’] ) ) { wp_redirect( add_query_arg( ‘author’, $user_ID ) ); exit; }
}

 

Código que mostra mídia do painel somente enviada pelo próprios autores

 

add_action(‘pre_get_posts’, ‘restringir_biblioteca’ );
function restringir_biblioteca($wp_query_obj){
global $current_user, $pagenow;
if(!is_a($current_user, ‘WP_User’)){
return;
}
if (‘admin-ajax.php’ != $pagenow or $_REQUEST[‘action’] != ‘query-attachments’){
return;
}
if(!current_user_can(‘manage_media_library’)){
$wp_query_obj->set(‘author’, $current_user->ID);
return;
}
}