WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Front-end Editor] allow editing only for certain category (7 posts)

  1. moramora9
    Member
    Posted 3 years ago #

    Hi, I'd like to make a "wiki" section in my blog, and only "wiki" category post have to be editable, and not for the rest of my blog post.

    How can I resolve my problem?
    I've read the previous thread and tried different solutions, but all thread were related to previous plugin version
    many thanks for attention

    marco

  2. scribu
    Member
    Posted 3 years ago #

    Hm... this topic didn't have the front-end-editor tag for some reason. That's why I missed it.

    Here's the updated code:

    function fee_specific_category( $allow, $args ) {
    	return $allow && in_category( 'wiki', $args['post_id'] );
    }
    add_filter( 'front_end_editor_allow_post', 'fee_specific_category', 10, 2 );

    See in_category() for more info.

  3. moramora9
    Member
    Posted 3 years ago #

    works! perfect!
    many many thanks!
    marco

  4. Fabio Polo
    Member
    Posted 3 years ago #

    Sorry, can you tell me where you have to place this code?

  5. Fabio Polo
    Member
    Posted 3 years ago #

    I think I have a similar problem:

    I'd like to make a "wiki" section in my blog, and only "wiki" pages have to be editable, and not for the rest of my blog. All my "wiki" pages have a custom file named "wiki".

    How can I resolve my problem?

    grazie!

    Fabio

  6. scribu
    Member
    Posted 3 years ago #

    You have to place the code inside your functions.php file.

    For restricting based on a custom field it would be:

    function fee_specific_custom_field( $allow, $args ) {
    	return $allow && get_post_meta( $args['post_id'], 'wiki', true );
    }
    add_filter( 'front_end_editor_allow_post', 'fee_specific_custom_field', 10, 2 );

    Note that this will still require users to be logged in and have the 'edit_pages' capability.

  7. Fabio Polo
    Member
    Posted 3 years ago #

    All works!
    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic