Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
requests-topic
Need new capability
Avatar
SoWhat
Member
Free Members
sp_UserOfflineSmall Offline
Mar 30, 2010 - 5:32 am

Hi!

 

My blog mostly contains contributor roles, who cannot publish posts, but can send them for activation to administrators.

So they are not able to create linked posts at all, because metabox for linked posts appears only to users who are allowed to publish posts.

I made a litle fix for this, it would be great if this could be included in next version:

# ------------------------------------------------------------------
# sf_blog_link_form()
#
# Filter call
# Sets up the forum post linking form in the Post/Page Write screen
# ------------------------------------------------------------------
function sf_blog_link_form()
{
    global $current_user;

    if(function_exists('add_meta_box'))
    {
        sf_initialise_globals();

        # can the user do this?
        if (!$current_user->sflinkuse) return;

        //if(current_user_can('publish_posts'))
        if(current_user_can('create_linked_posts'))
        {
            add_meta_box('sfforumlink', esc_attr(__("Link To Forum", "sforum")), 'sf_populate_post_form', 'post', 'advanced');
        }
        if(current_user_can('publish_pages'))
        {
            add_meta_box('sfforumlink', esc_attr(__("Link To Forum", "sforum")), 'sf_populate_post_form', 'page', 'advanced');
        }
    }
    return;
}

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 30, 2010 - 8:18 am

and this also creates a new wp capability? how was that added? another plugin? and btw, you should be able to put that in your functions.php file of your theme and be good to go...  hopefully, with plugins on the plan for 5.0, this would be a nice example of one!

Avatar
SoWhat
Member
Free Members
sp_UserOfflineSmall Offline
Mar 30, 2010 - 10:15 am

no, it doesn't create new capability, but it isn't hard to write a script that does it. I created capability with Role Manager plugin.

 

Thanks for advice! I added following code to my themes functions.php, you are welcome to correct my code because I am a beginner in PHP:

# ——————————————————————# sf_my_blog_link_form()## Adds metabox to users who are allowed to create_linked_posts# ——————————————————————function sf_my_blog_link_form(){    if (!function_exists('add_meta_box')) include('/problem-with-post-edit-buttonome/transformators/transformators.lv/wp-admin/includes/template.php');    global $current_user;                sf_initialise_globals();                # can the user do this?            if (!$current_user->sflinkuse) return;                if(current_user_can('create_linked_posts'))            {                add_meta_box('sfforumlink', esc_attr(__("Link To Forum", "sforum")), 'sf_populate_post_form', 'post', 'advanced');            }    return;}sf_my_blog_link_form();

Anyway, it would be nice, if you could include this in next release, because I am probably not the only one who needs this.

 

PS. Can't understand whats wrong with code formatting.

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625