1

We are building a site that will have 10-15 photographers posting content. There will be a common blog + each admin has their own portfolio to manage. "Portfolio galleries" and "portfolio pages" are two custom types and they are categorized using "Artist", a custom taxonomy.

We would like all admins:

  1. to be able to see all blog posts
  2. be able to post in the blog
  3. be able to add new "portfolio galleries" and "portfolio pages" and have them automatically tagged with the "artist" taxonomy with the same value as their name (i.e. John Smith will be able to only create portfolio pages and galleries automatically tagged with *Artist = "John Smith"*)
  4. be able to only view portfolio pages and galleries that belong to them (i.e. John Smith will only see portfolio pages and galleries that are marked with *Artist = "John Smith"*)

Finally we would also like to have a couple of "super admins" that will have access to every post on the site.

Any ideas on how to go building something like this? Is it even feasible?


EDIT Following @בניית אתרים suggestion I have read a bit more about Roles and Capabilities and realized that Wordpress already supports out of the box the ability to limit users from editing other people's posts. All I needed to do was to switch all the users to be Authors instead of Editors.

In brief #1, #2 and #4 from the above list are resolved. I still need to get #3 to work using save_post.

2 Answers 2

3

Short: yes you can do that.

to be able to see all blog posts

the default editor role can manage to see all posts

be able to post in the blog

again the default editor role can manage to see all posts

be able to add new "portfolio galleries" and "portfolio pages" and have them automatically tagged with > the "artist" taxonomy with the same value as their name (i.e. John Smith).

For that you can use the save_post hook and automatically add there username as taxonomy.

be able to only view portfolio pages and galleries that belong to them (i.e. John Smith will only see > portfolio pages and galleries that are marked with Artist = "John Smith")

when registering post types you can define capabilities for that post type and you need to define edit_others_posts as false, also make sure that your post type supports author.

Finally we would also like to have a couple of "super admins" that will have access to every post on the site.

the default admin role is your friend in this case. basically most of your issues are with Roles and Capabilities

hope this helps

2
  • Thanks for your answer. Very thorough and very interesting. I am not sure how to use the save_post hook. Is there any example of how to do it online? I searched in the WP docs and the page for save_post hook is missing. Feb 21, 2011 at 23:56
  • Like you said, I was able to limit access to their own posts only by switching all the users to be "authors" instead of "editors". Makes sense. Still working on the idea of hooking into the save_post to add custom taxonomies on save. Feb 22, 2011 at 1:36
2

If I will be the one building that site, this is what I'll do for the "View Portfolio Pages and Galleries that belong to them":

1.) I'll create a new page template, say template-portfolio.php inside your themes directory, that goes something like this:

<?php
/*
Template Name: Portfolio
*/
if(is_user_logged_in() && current_user_can('manage_options'))  //ensure that it is an admin, as per requirements
{
   global $current_user;
   get_currentuserinfo(); //information shall be stored in $current_user
   // echo 'User ID: ' . $current_user->ID . "\n";

   query_posts(array('Artists' => $current_user->display_name));

    //do the loop here.

}
else
{
  wp_redirect(get_bloginfo('url')); //go to home page if not logged in or if not admin
}
?>

2.) I would create a Page in wordpress and assign Portfolio as the Page Template

3.) I would view the Page using page preview, and if it works, I'll pat myself in the back ;)

You can do a variant of the flow here for your other concerns.

1
  • Not sure that's what he asked.
    – Bainternet
    Feb 16, 2011 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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