Tagged: taxonomy
- This topic has 5 replies, 2 voices, and was last updated 6 years, 12 months ago by
Steve.
-
AuthorPosts
-
-
February 13, 2015 at 12:04 pm #3310
vondervickMemberHi Steve, you created an awesome tutorial ‘Creating Separate Taxonomies for each User’, but the thing is I’m working with subscriptions and I have (ie. user-1 -> subscribed to -> user-2) where user-2 has custom tax. Ok so, in the front end the logged user-1 has access to content of user-2 but when I try to list the categories it says:
WP_Error Object ( [errors:WP_Error:private] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy ) ) [error_data:WP_Error:private] => Array ( ) )Created taxonomy:
array( 'post_type' => $_post_type ,'name' => 'meal_category_' . $current_user->ID // in this case $current_user->ID = user-2 ,'configuration' => array( 'hierarchical' => true ,'labels' => piklist('taxonomy_labels', "Category") // Append user name to Taxonomy labels ,'show_ui' => true ,'query_var' => true ,'rewrite' => array( 'slug' => 'mc_' . $current_user->ID // Append user ID to taxonomy slug ) ,'show_admin_column' => true ,'comments' => true ) )so my real question is: How to display custom taxonomies in the front of that specific user (user-2). thx
-
February 13, 2015 at 12:13 pm #3311
SteveKeymaster@vondervick– Welcome to the Piklist community!
That tutorial was inspired by another Piklist user that wanted that kind of functionality. The goal was to give each LOGGED IN user their own taxonomy. If User One is logged in, then only that taxonomy is registered… the other taxonomies don’t even exist.
It doesn’t sound like this is the type of functionality you really want.
What functionality are you trying to achieve?
(I moved this topic to it’s own post since it had nothing to do with the original)
-
February 13, 2015 at 12:29 pm #3314
vondervickMemberOk, users ( Trainer , client )
1. Create separate taxonomies for trainers inside custom post (done)
2. Make those taxonomies available only for clients subscribed to the trainerQuestion: if there any other way to do this using piklist, or regular WP functions
Note: I’m trying to create a shortcode of this so I can place it anywhere on the frontend -
February 13, 2015 at 12:56 pm #3315
SteveKeymasterThis is totally untested. The only thing I don’t know is how you are associating a Client to a Trainer. You will have to fill in that logic.
add_filter('piklist_taxonomies', 'my_custom_taxonomies'); function my_custom_taxonomies($taxonomies) { global $current_user; get_currentuserinfo(); if (current_user_can('edit_posts')) // You're a Trainer { $trainer_id = $current_user->ID; } else // You're a Client { // Find the association between the Client and Trainer. // Get the Trainer's user_id. $trainer_id = $trainer->ID; } $trainer_info = get_userdata($trainer_id); // Get all user info for Trainer // Register Taxonomy for the Trainer $taxonomies[] = array( 'post_type' => array('post') ,'name' => 'personal_tags_' . $trainer_id // Append User ID to taxonomy name ,'configuration' => array( 'hierarchical' => false ,'labels' => piklist('taxonomy_labels', $trainer_info->display_name . "'s Tag") // Append user name to Taxonomy labels ,'show_ui' => true ,'query_var' => true ,'rewrite' => array( 'slug' => 'personal_tags_' . $trainer_id->ID // Append user ID to taxonomy slug ) ,'show_admin_column' => true ,'comments' => true ) ); return $taxonomies; }Let me know if this makes sense.
-
February 13, 2015 at 2:10 pm #3316
vondervickMemberlet’s try this, you already have created taxonomies for trainers, now in the frontend you want to list al categories for every trainer
i.e
Trainer 1 Meals - Breakfast - Lunch ... Trainer 2 Meals - Under 1500 Calories - Lean - ..the trainers are going to be filtered by subscription of the client, but right now i’ll keep it simple just like the code above, for every client ‘no conditions’ just public access.
any thoughts or ideas or bit of code or directions would be appreciated. thx in advance
-
February 13, 2015 at 4:41 pm #3317
SteveKeymaster@vondervick– This is getting a bit confusing. Without seeing all your code I don’t think we can help you much. Feel free to zip it up and email to [email protected]
-
-
AuthorPosts
- You must be logged in to reply to this topic.