Tagged: 

Viewing 5 reply threads
  • Author
    Posts
    • #3310
      vondervick
      Member

      Hi 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

    • #3311
      Steve
      Keymaster

      @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)

    • #3314
      vondervick
      Member

      Ok, users ( Trainer , client )
      1. Create separate taxonomies for trainers inside custom post (done)
      2. Make those taxonomies available only for clients subscribed to the trainer

      Question: 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

    • #3315
      Steve
      Keymaster

      This 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.

    • #3316
      vondervick
      Member

      let’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

    • #3317
      Steve
      Keymaster

      @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]

Viewing 5 reply threads
  • You must be logged in to reply to this topic.