I have a custom post type call question which have custom taxonomies which is called question-tags. These question tag further used for creating dynamic quiz. I want to restrict users to use question-tags created by them only. They cann't access tags created by others. How it is possible?
Just let me know how to make tags private for each user so they cann't use tags create by each other in front end forms
I have a custom post type call question which have custom taxonomies which is called question-tags. These question tag further used for creating dynamic quiz. I want to restrict users to use question-tags created by them only. They cann't access tags created by others. How it is possible?
Just let me know how to make tags private for each user so they cann't use tags create by each other in front end forms
This is a possible way of doing this. Whenever a new term is created, you execute the following code.
This code saves the current user_id as the term author, which should allow you to filter by user_id when fetching terms.
add_action( 'created_term', 'filter_user_specific_term', 10, 3 );
function filter_user($term_id, $tt_id, $taxonomy){
if( $taxonomy == "my_custom_taxonomy"){
if (isset($term_id)) {
add_term_meta ($term_id, "author", get_current_user_id());
}
}
}
To get the term list, according to current user:
$terms = get_terms( array(
'taxonomy' => 'my_custom_taxonomy',
'meta_key' => 'author',
'meta_value' => get_current_user_id() ) );
I didn't test this code but should be a good start point for doing what you want.