I have only frontend block, and I need restrict category to only logged in User, so The Author create category and this category view only this current author, not another user. Its here any way/plugin in wordpress?
edit1: My question is simmilar, like here: Restricting Users to view only Custom Taxonomies they have entered? but I don´t know how it implement for my.
edit2: I add meta terms field to taxonomie with this plugin: / So I parrent user meta with taxonomie (category). How can I implement get_terms and wp_dropdown_cats and show taxonomie for only current logged in Author (Frontend User)?
I have only frontend block, and I need restrict category to only logged in User, so The Author create category and this category view only this current author, not another user. Its here any way/plugin in wordpress?
edit1: My question is simmilar, like here: Restricting Users to view only Custom Taxonomies they have entered? but I don´t know how it implement for my.
edit2: I add meta terms field to taxonomie with this plugin: https://fuc.wordpress.org/plugins/wp-custom-taxonomy-meta/ So I parrent user meta with taxonomie (category). How can I implement get_terms and wp_dropdown_cats and show taxonomie for only current logged in Author (Frontend User)?
Inside while loop of single.php you can put condition like this
if(in_category('Catetory_slug')){ //Specifying category whom we don't want to see by no logged in users
if(is_user_logged_in()){ //Checking if user logged in or not
//code inside single.php
}else{
Echo "You need to login to view this post."; //message for no logged in users
}}
This can be done for other template of theme files like we did for single.php.
UPDATE
If you want one user couldn't see posts of another user then you can use these two functions to achieve this
Use following inside while loop
//storing autor's display name in variable
$post_author = get_the_author();
$current_user = wp_get_current_user();
//storing autor's display name in variable
$current_user_info = $current_user->display_name;
//Chacking if bot strings (display names) are equal or not
if (strcmp($post_author, $current_user_info) == 0) {
//Your Code to display post's content
}
You can also put if condition on ID instead of display name. For that you need to make 2 changes in above code
get_the_author()
function with get_the_author_meta()
and replace following line of code
$current_user_info = $current_user->display_name;
with this
$current_user_info = $current_user->ID;
To know more read about this functions in detail in my given link.