• Is it possible to restrict a user to being able to post (write) to one category only?

    What I want to do is use WordPress as a news fed site for an online mall. Each user on the site is a store owner in the mall, and I wanted to make it so that when they log in and write a post, the post will be written to ‘their’ category.

    For instance, Mary owns ‘A Dolls World” which is a store in the mall. So I create a category called “A Dolls World”

    When Mary logs in and goes to write a post, the way it is now is that she can select which category she will post in. But as many new users are likely to do, she may forget to check ‘her’ category and post to the default category instead. I would like to make it so that she can only post in her own category.

    Is this possible?

    And, BTW, perhaps there’s a better way of doing this altogether. Allow me, if you will, to ask this:

    My idea is to create a category for each store in my mall and allow store owners to have their own news feed.

    My limited experience with WordPress allowed me only one idea on how to do this; by setting up a category for each store owner.

    This way, every time a store owner posts a news item, (and assuming the user put the item in their own category, the item would show up on the front page as well as in their category. Fans of that user could subscribe to that particular category, which would keep them updated on anything new in that users store.

    The news item would also show up on the front page, allowing fans of the entire mall to subscribe to the entire site rather than one or two individual stores.

    Is this one-category-per-store the best way to accomplish this, or am I missing some bigger picture.

    Thanks!

Viewing 10 replies - 31 through 40 (of 40 total)
  • Brace yourselves, here comes the ugliest hack in the world!

    Basically, this involves some slight edits to the function that generates the checkboxes to select a category when a post is made. It checks for the user you want to restrict, then it checks if you’ve encountered the category you want to display.

    Criticisms are gladly welcomed…I just spent several hours searching for an elegant way of doing this through plugins and nothing satisfactory turned up(I’m using php5 and read that limit categories plugin doesn’t work with it…not to mention that the site was done when I checked.)

    This code is highly specialized to what I needed it to do which is to have an events user be limited to only post to the events category. But you get the idea…

    [code]
    function write_nested_categories($categories) {
    global $current_user;

    $evt_user_id = 3;
    $evt_cat_id = 3;
    foreach ($categories as $category) {
    //if events user
    if($current_user->id == $evt_user_id){
    //only display category if its the events category
    if($category['cat_ID'] == $evt_cat_id){
    echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>n";

    if (isset ($category['children'])) {
    echo "n<span class='cat-nest'>n";

    write_nested_categories($category['children']);
    echo "</span>n";
    }
    }//end if its the events category
    }//end if user is events user
    else{
    echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>n";

    if (isset ($category['children'])) {
    echo "n<span class='cat-nest'>n";

    write_nested_categories($category['children']);
    echo "</span>n";
    }
    }
    }//end foreach
    }

    [/code]

    i’m a newbie i know…but am I not using the right syntax([code][/code]) to get the code above to appear as code?

    It’s been a while since anybody posted on this – if there’s still anybody out there who wants a solution come back and repost.

    I have a solution that requires a minor mod to admin_functions.php.

    Gosh, I’m trying to do the same thing but having no luck in admin_functions.php. Would you mind sharing your solution?

    Sure no problem – you can see it here https://blog.irelandonthenet.ie/?p=10

    rburke, there was a problem with the original code posted – don’t know what happened but it was incorrect – I’ve corrected it for WP 2.0.7 and also an update for WP 2.1 – apologies for any confusion

    “Can you restrict users to write to only 1 category?”

    Yep. Plugin to do just this in WP2.1 coming *very* soon.

    ;o)

    OK,
    What I can gleam from all this is that Limit Categories works with 2 (does it work with 2.1?) but not if running php5.

    I am running 2.1 on php5, and I do not like the idea of downgrading php5 just to make one plugin work. However, this plugin is not working. (When activated, I can’t even go to the Manage Categories admin section without getting an Internal Server Error.)

    To reiterate, I don’t need per-user limits for categories, just per-role limits. Is there a solution out there?

    Hi,

    I have this working using role manager and limit cats but what happens when I go to post from a user to their category I get this error:

    Warning: array_intersect(): Argument #2 is not an array in /home/cavecrek/public_html/blogsite/wp-content/plugins/limitcats.php on line 357

    Warning: Cannot modify header information – headers already sent by (output started at /home/cavecrek/public_html/blogsite/wp-content/plugins/limitcats.php:357) in /home/cavecrek/public_html/blogsite/wp-includes/pluggable.php on line 275

    Anyone know what this could be???

    Been searching for something similar to this, and found
    https://dev.wp-plugins.org/wiki/Userextra. I haven’t tried it yet, but obviously this thread keeps getting revisited, so must be something people are looking for. It’s supposed to work in tandem with https://dev.wp-plugins.org/wiki/Usermeta.

    HTH ??

Viewing 10 replies - 31 through 40 (of 40 total)
  • The topic ‘Can you restrict users to write to only 1 category?’ is closed to new replies.