Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom role, "Ministry Representative", which is able to log in and create and manage their own "Opportunities" and "Events", which is each a custom post type.

On the front end of the site, you can filter opportunities or events by "Ministry", which is a custom taxonomy associated with both the "Opportunities" and "Events" custom post type.

On the backend, I create an account for a "Ministry Representative" to manage what appears on their profile as well as within the filtered results on the "Opportunities" and "Events" index pages.

The Challenge

When a "Ministry Representative" goes to create a new "Event", they enter the details, and, from the custom taxonomy, they have to choose:

  • Location (a hierarchal custom taxonomy)
  • Presenter (a non-hierarchal custom taxonomy)
  • Ministry (a non-hierarchal custom taxonomy)

So, in essence, they have to choose themselves. John Doe, who is a "Ministry Representative" for "Ministry A", has to choose his own ministry from a dropdown (a custom meta box via WP Alchemy).

The Ideal Solution

Ideally, when a new "Event" or "Opportunity" is created by John Doe of "Ministry A", the association is made without any input required on the interface level by the end-user.

So, what I think I'm looking for is a way to associate a user account with a specific term within a custom taxonomy.

Does that make sense? Is there, perhaps, another way to look at the problem? As I'm imagining, I could see other applications which could make this useful. An account is created and when X user contributes a given type of content, pre-selected terms are automatically associated to their contributed content.

Any thoughts or ideas are greatly appreciated. Thank you!

share|improve this question

2 Answers 2

up vote 4 down vote accepted

I was able to come up with a work around! First, I used Role Scoper to limit a user account to a specific term - in this case, a Ministry Representative is limited to the name of their Ministry in the "ministries" taxonomy. Then, I used the WPAlchemy class to create a custom metabox that would list the terms and, since it only returned one (theirs), I would have it already selected. Next, I hid it via an admin stylesheet.

The effect is that, when a Ministry Representative creates a new Event or Opportunity, their ministry name is already selected (though they don't see it) and the association is made on save. It requires a bit of work on the part of the admins to setup the term and I would still like a cleaner way of doing the same if it exists.

If anyone would like further details on my work-around, let me know.

share|improve this answer
    
Interesting solution. Can you click the checkbox to indicate you solved this problem and you don't need other answers? Also, John will only get notified of comments to his answer, not new answers, so you might want to move your first sentence to a comment. –  Jan Fabry Dec 29 '10 at 8:05
    
@Jan - I made the updates per your suggestion - Thank you! I'm learning my way around here :)! –  Jonathan Wold Jan 19 '11 at 21:24

I think you should use usermeta to accomplish this. For example, have the user's 'ministry' set on their profile (it would basically just be a list of the terms in that taxonomy) and save the tax_term_id as a usermeta. Additionally, you should create a new term in the Presenter taxonomy, using the user_login as the term name to ensure one unique term per presenter. There's no need to save this tax_term_id in the usermeta, though. Location could also be set from the profile and saved in usermeta, but it might make more sense to just use the default UI that WordPress uses.

Once you have all of that set up, you would want to hook into the 'save_post' action to make sure that all of these terms get applied to the post as it's saved, etc.

That being said, I don't understand why you'd need a taxonomy directly related to the presenter, since you can already query for the author of a post.

share|improve this answer
    
Thank you for the reply! I may have been unclear, but there is no need to relate the taxonomy to the presenter. –  Jonathan Wold Jan 19 '11 at 21:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.