WordPress.org

Ready to get started?Download WordPress

Forums

Front-end Editor
[resolved] Editors not able to edit editable_option (7 posts)

  1. vernal
    Member
    Posted 4 years ago #

    Hey Scribu,

    I'm running latest FEE on latest wp. Editors are not able to edit editable_option fields but can certainly edit page content/titles/thumbnails. Admins can edit editable_options without a problem. Ideas?

    Best,
    Jason

  2. scribu
    Member
    Plugin Author

    Posted 4 years ago #

    That's because only admins have the 'manage_options' capability.

    In the development version, I changed it to 'edit_themes' (the same as for text widgets).

    Have you considered using editable_post_meta() instead?

  3. vernal
    Member
    Posted 4 years ago #

    Ah, ok. Perfect!

    I replaced this:
    <?php editable_option('about'); ?>

    With this:
    <?php editable_post_meta(get_the_ID(), 'about', 'textarea'); ?>

    And now it's great.

    Thanks as always for your help.

  4. vernal
    Member
    Posted 3 years ago #

    Hey Scribu,

    I'm back on this issue. I yet to come up with a solution that will allow for an editable text block (editable_option) that exists OUTSIDE of the loop yet is editable by editors. I can't seem to get a good solution going. Ideas?

  5. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    The trouble is that editors need to have the 'edit_themes' capability.

    In other words, if they can edit widgets, they should be able to edit editable options too.

  6. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    If you're sure that's not necessary, you can add this code in your theme's functions.php:

    function my_fee_fields() {
    
    	class Custom_FEE_Field_Option extends FEE_Field_Option {
    
    		function check( $data = 0 ) {
    			extract( $data );
    
    			$cap = ( 0 === strpos( $key, 'editable_option_' ) ) ? 'edit_others_posts' : 'manage_options';
    
    			return current_user_can( $cap );
    		}
    	}
    
    	fee_register_field( 'editable_option', array(
    		'class' => 'Custom_FEE_Field_Option'
    	) );
    }
    
    add_action( 'front_end_editor_fields', 'my_fee_fields' );

    You can replace 'edit_others_posts' with any other capability, if you need to.

  7. vernal
    Member
    Posted 3 years ago #

    Ok great. In this case there is no problem with the editor having the ability to edit themes, so i turned that on via capability manager and we're good to go. Thanks for the clarification and the function for future projects.

    Jason

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic