Forum Replies Created

Viewing 15 replies - 1 through 15 (of 43 total)
  • Nah not what I want 🙁

    SOrry no, I’m not a PHP genius so I can’t edit that code as I don’t know what it means 🙁 I was hoping someone else who’s very familiar with it could change to the code

    I had an idea – you add a new field in the $user_data and call it user_catid

    So started editing this:

    <?
    /*
    Plugin Name: Limit Categories
    Plugin URI: http://www.asymptomatic.net/wp-hacks
    Description: Limits the categories to which users of certain levels can make posts.
    Version: 1.1
    Author: Owen Winkler
    Author URI: http://www.asymptomatic.net
    */
    /*
    Limit Categories - Limits the categories to which users of
    certain levels can make posts.

    This code is licensed under the MIT License.
    http://www.opensource.org/licenses/mit-license.php
    Copyright (c) 2005 Owen Winkler

    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated
    documentation files (the "Software"), to deal in the
    Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software,
    and to permit persons to whom the Software is furnished to
    do so, subject to the following conditions:

    The above copyright notice and this permission notice shall
    be included in all copies or substantial portions of the
    Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
    KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
    WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
    OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    */

    $limit_minlevel = 2; // The minimum level you need to see ALL categories.
    $limit_onlycats = array('Uncategorized', 'FFAF'); //The categories that you can see when you have a low user level
    $limit_dosubcats = true; // Show subcategories for the limited categories

    add_action('admin_head', array('catlimit', 'admin_head'));

    class catlimit {
    function admin_head($unused) {
    global $userdata, $limit_minlevel;
    get_currentuserinfo();

    if($userdata->user_level < $limit_minlevel) {
    if(preg_match('|/wp-admin/post.php|', $_SERVER['REQUEST_URI'])) {
    ob_start(array('catlimit', 'ob_done'));
    }
    }
    }

    function ob_done($content) {
    return preg_replace('|<fieldset id="categorydiv">.*?</fieldset>|sie', 'catlimit::return_catshell();', $content);
    }

    function return_catshell() {
    $output = '<fieldset id="categorydiv"><legend><a href="http://wordpress.org/docs/reference/post/#category&quot; title="' . __('Help on categories') . '">' . __('Categories') . '</a></legend><div>';

    $categories = get_nested_categories();
    $output .= catlimit::return_catlist($categories);

    $output .= '</div></fieldset>';
    return $output;
    }

    function return_catlist($categories, $use_children = false) {
    global $limit_onlycats, $limit_dosubcats;

    foreach($categories as $category) {
    if($use_children || in_array($category['cat_name'], $limit_onlycats)) {
    $output .= '<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($limit_dosubcats && isset($category['children'])) {
    $output .= "n<span class='cat-nest'>n";
    $output .= catlimit::return_catlist($category['children'], true);
    $output .= "</span>n";
    }
    }
    }
    return $output;
    }
    }
    ?>

    to get this:

    <?
    /*
    Plugin Name: Limit Categories
    Plugin URI: http://www.asymptomatic.net/wp-hacks
    Description: Limits the categories to which users of certain levels can make posts.
    Version: 1.1
    Author: Owen Winkler
    Author URI: http://www.asymptomatic.net
    */
    /*
    Limit Categories - Limits the categories to which users of
    certain levels can make posts.

    This code is licensed under the MIT License.
    http://www.opensource.org/licenses/mit-license.php
    Copyright (c) 2005 Owen Winkler

    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated
    documentation files (the "Software"), to deal in the
    Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software,
    and to permit persons to whom the Software is furnished to
    do so, subject to the following conditions:

    The above copyright notice and this permission notice shall
    be included in all copies or substantial portions of the
    Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
    KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
    WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
    OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    */

    $limit_minlevel = 5; // The minimum level you need to see ALL categories.
    $limit_onlycats = echo'$userdata->user_catid'; //The categories that you can see when you have a low user level
    $limit_dosubcats = true; // Show subcategories for the limited categories

    add_action('admin_head', array('catlimit', 'admin_head'));

    class catlimit {
    function admin_head($unused) {
    global $userdata, $limit_minlevel;
    get_currentuserinfo();

    if($userdata->user_catid ='0') {
    if(preg_match('|/wp-admin/post.php|', $_SERVER['REQUEST_URI'])) {
    ob_start(array('catlimit', 'ob_done'));
    }
    }
    }

    function ob_done($content) {
    return preg_replace('|<fieldset id="categorydiv">.*?</fieldset>|sie', 'catlimit::return_catshell();', $content);
    }

    function return_catshell() {
    $output = '<fieldset id="categorydiv"><legend><a href="http://wordpress.org/docs/reference/post/#category&quot; title="' . __('Help on categories') . '">' . __('Categories') . '</a></legend><div>';

    $categories = get_nested_categories();
    $output .= catlimit::return_catlist($categories);

    $output .= '</div></fieldset>';
    return $output;
    }

    function return_catlist($categories, $use_children = false) {
    global $limit_onlycats, $limit_dosubcats;

    foreach($categories as $category) {
    if($use_children || in_array($category['cat_name'], $limit_onlycats)) {
    $output .= '<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($limit_dosubcats && isset($category['children'])) {
    $output .= "n<span class='cat-nest'>n";
    $output .= catlimit::return_catlist($category['children'], true);
    $output .= "</span>n";
    }
    }
    }
    return $output;
    }
    }
    ?>

    But I don’t know where to go from there as the rest is gibberish!

    I hope you can understand from what I have changed what I want to accomplish and then edit the code for me 😀

    The only problem then is getting a way to add the new field into the profile so only admin can edit it :S

    BTW These are the edit’s I made:

    $limit_minlevel = 5; // The minimum level you need to see ALL categories.
    $limit_onlycats = echo'$userdata->user_catid'; //The categories that you can see when you have a low user level
    $limit_dosubcats = true; // Show subcategories for the limited categories

    add_action('admin_head', array('catlimit', 'admin_head'));

    class catlimit {
    function admin_head($unused) {
    global $userdata, $limit_minlevel;
    get_currentuserinfo();

    if($userdata->user_catid ='0') {

    Can be found in there. Where I said if($userdata->user_catid =’0′) {
    I basically wanted to say that

    if {$userdata->user_catid=”0″} //Admin will be 0

    then {$post_ability=”all”} //They can post everywhere

    else {$userdata->user_catid=$post_ability}; ?> //Else they post in the category corresponding to their catid

    Hope you can help and that this made sense…….
    (Im a a php newbie at the moment 🙁 )

    andre_gr how’s this coming along?

    Forum: Plugins
    In reply to: Group Members
    Thread Starter infnit

    (@infnit)

    Hey has anyone written a plugin for WordPress Strayhorn which will allow users to be grouped.

    I want to group authors into regions for example:

    Category: New York
    Sub-Category: New York High
    Group: New York High
    Group Members:
    Mr. Teacher (User Level 3)
    Billy (User Level 1)
    Sandy (User Level 1)
    John (User Level 1)
    Andy (User Level 1)
    Jesse (User Level 1)

    Now Mr. Teacher can edit Billy, Sandy, John, Andy and Jesse’s Post but not the people on Level 1 and 2 in Group Washington DC High.

    Also Group New York High can only post in New York High.

    Can you help me?

    Forum: Plugins
    In reply to: Group Members
    Thread Starter infnit

    (@infnit)

    I have an idea!

    You know Custom Fields, can you let the author choose a custom tag, like which ever Group he belongs to – and then only people who have access to that custom field can edit it.

    (A modification to the View Level or similar plugin)

    Anyone working n this?

    I also want this…

    Forum: Plugins
    In reply to: Group Members
    Thread Starter infnit

    (@infnit)

    Like the idea is that person’s in Group 3 can only post to Cat_Bob and modify/edit post in Cat_Bob

    Forum: Plugins
    In reply to: Group Members
    Thread Starter infnit

    (@infnit)

    Yes, but someone on Level 3 can edit anyone below them. Not just people in his/her “group”

    I asked someone on MSN and they said this:
    <?php
    global $user_login;
    get_currentuserinfo();
    if ($user_login){
    echo '<a href="wp-admin/">Dashboard</a><br />
    <a href="wp-admin/profile.php">Edit my Profile</a><br />
    <a href="wp-admin/post.php">Submit an Article</a><br />'
    ;
    }
    else {
    echo '<a href="wp-register.php">Not Registered? Click here!</a>';
    }
    ?>

    What if I want to display something when the person is not logged in? Like
    Not Registered? Register Today!

    PS: I want to do this because I want to remove Site Admin link as I am making links like Submit and Article and Edit my Profile.

    Thanks it worked!
    Jo5329 you have to replace the ul that is already there…..

    It works if I copy the “contents” of the files into their respective places. Using includes doesn’t work

    Didn’t work – I have 1.5 If it;d help

Viewing 15 replies - 1 through 15 (of 43 total)