Yippee Ki Yay. Get me a Beer.
Recently I posted about a Wordpress issue that I needed to get sorted;
One of my blogs is ripe to turn into a community blog on which people can sign up as an author and then post into their own “category”.
Basically my idea was to allow people to sign up as an author, then link their author name to a category. Then allow them to post ONLY to that category. Easy, right…
Beeeeeppppppp. Wrong.
It really was not easy at all. For starters, my idea about using categories was a no-go as I wanted the site URLs to be like this;
http://www.mysite.com/dave/post.html
but when using categories, Wordpress automatically pre-pends the word "category" into the permalink, thus it would actually be;
http://www.mysite.com/category/dave/post.html
Well, that was the first problem I needed to get sorted. As I am in no way a Wordpress Expert, this took some time but eventually I found a plugin which does exactly this - Top Level Categories from fortes.com. Once "plugged in" and activated, this works exactly as I require
Next up, I needed to link a categories to an Author. This was more problematic as I found no plugin already completed
After much searching I found "user extra" and "user meta". These give the ability to "assign" information to a User. Once plugged in and activated, I was able to assign category to author (using the "Allow these locked categories" setting in manage > Extra User Data)…
Well this worked great, except that it would be impossible to keep updating the Categories that the Author is NOT allowed to post to. After all, each time I add a new Category for a new Author I would have had to update every Author so that all the existing Authors had no posting rights in the new category. Does that make sense?
As I am a bit of a PHP Hacker, I delved into the murky underbelly and came to see that the two options for category posting by author; "allowed" and "disallowed" are simply compared to each other in a simple array. With a bit of jiggery pokery I amended that compare to just check inside the "allowed" array, and only show those categories whilst the Author is logged in. Sounds more complicated than it is.
Suffice to say that I now have a working example of what I want to do, so it's full steam ahead for my new community blog. I hope to get a lot of authors on board. I'll update as time goes by.
Conclusion
Get me a Beer, someone, please.

Comment by gary — June 7, 2007 @ 8:12 pm
After some more testing, it seems to be working well. Next on the "to do" list for this project is to allow the Author to choose their own "category" name when signing up. I'm thinking a kinky little Ajax checking script, to make sure that their chosen category name does not exist would be just the job.
First though is to actually get it working, then gussy it up with the Ajax.
Then, the whole thing will be totally hands off. I'll update as I get things working!
Comment by gary — June 8, 2007 @ 12:02 am
Replying to oneself is not a good sign
Amazing how when you start a small project, it sort of snowballs into something larger than originally planned.
I decided I can't go fully automated due to possibe spam issues. Don't want nefarious sods signing up and then putting v_i_a_g_r_a posts everywhere. So, I'm keeping the authorisation on a manual basis.
I've now amended the wp-admin/dashboard page so that when a "new" user logs in (that is a user that has not been authorised yet), he sees a nice message stating so. Once authorised, he can post into his own category. So that's working really well now. Next up is what I put in the previous post, which should be "interesting" coding…