• Is it possible to configure this plugin so admins can embed images when they post comments but ordinary users cannot?

Viewing 1 replies (of 1 total)
  • Quick and dirty using a filter

    add_filter( 'comment_text', function( $text, $comment ){
        static $removed = false;
        /** @var WP_Comment $comment */
        if ( ! user_can( $comment->user_id, 'manage_options' ) ) {
    	    remove_action('comment_text', 'comments_img_embed', 2);
    	    $removed = true;
        } else {
            if( $removed ) {
    	        add_action( 'comment_text', 'comments_img_embed', 2 );
    	        $removed = false;
            }
        }
        return $text;
    }, 1, 2 );

    I just happened to be working on the same thing.

Viewing 1 replies (of 1 total)
  • The topic ‘Embed images for admins only?’ is closed to new replies.