Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

this may be a step too far but I publish occasional tutorials on my personal blog and sometimes in comments get asked questions where an image would be very helpful to include as the answer. I've done a plug-in search and also looked for code but come up with nothing. Is there any way I can allow those with Admin role to upload an image as part of their reply to a comment? I don't want to allow readers to upload images really. Also I'm not really looking to add a link to an image in the reply, I'd ideally like it in the comment reply itself. Just a 'too difficult' or 'can't be done' response would put me out of my misery :-)

share|improve this question
    
Did you come across this plugin: wordpress.org/extend/plugins/comment-images You could just edit the code and set the currect_user to an admin capability for the upload. –  Christine Cooper Jan 21 '13 at 16:06
    
Hi Christine, thank you I saw that plugin but didn't think about editing it I must admit. I think you could have the solution though. I'm not sure what files it includes but would it just be a case of surrounding some code somewhere with: <?php if (current_user_can( 'manage_options' )) { ...code from plug-in here... } ?> and this code would prevent the option to upload an image on my comments form from appearing unless a site admin were logged in? –  Paul Brown Jan 21 '13 at 16:21
    
Yes indeed, it is a very simple process, please check the answer that I posted. –  Christine Cooper Jan 21 '13 at 16:54
add comment

1 Answer

up vote 1 down vote accepted

The easiest and quickest way that you can do this is by downloading the Comment Images plugin and limit access to the upload feature by the function current_user_can. As the WP page demonstrates, use:

if ( current_user_can('manage_options') ) {
 // Plugin code here
}

I had a very quick look at the plugin code and you may need to add this function to the add_image_upload_form function. All and all, this should only take you a few minutes to setup.

share|improve this answer
1  
Hi Christine, I accepted the answer. I've added the plug-in and it does as expected. Haven't yet tried to edit the code and add the restriction as I have to race out but from your response that seems to make perfect sense to me. I'll have a play later. –  Paul Brown Jan 21 '13 at 17:12
    
Good luck and let us know if it doesn't work out and we will assist. –  Christine Cooper Jan 21 '13 at 17:30
1  
Hi Christine, I added the edit to plugin.php at line 169 if ( current_user_can('manage_options') ) { and then to close it at line 182 } and as far as I can see it works as expected. The image I already added by way of reply shows to all but the option to upload images only shows to me. I have tested new comments both logged in (as admin) and logged out (posting as guest) to test and all appears fine to me. –  Paul Brown Jan 21 '13 at 22:36
    
Glad to hear it Paul and good luck with your site. –  Christine Cooper Jan 22 '13 at 14:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.