Display list of uploaded images, filtered by user under a specific user group

This example loops through all photographers and then displays all images uploaded by them: <ul> <?php $photographers = get_users( ‘role=photographer’ ); foreach( $photographers as $user ) : $pictures = new WP_Query( array( ‘author’ => $user->ID, ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inheret’, ‘posts_per_page’ => -1 ) ); echo ‘<li><h3>’ . $user->user_nicename . ‘</h3>’; if ( $pictures->posts … Read more

Using WAMP, trying to create a plugin, getting error: You do not have sufficient permissions to access this page

administrator isn’t a capability, it is a role, so the reason you get that error is because WordPress doesn’t recognizes the capability you gave. If you look up the capabilities of the administrator role, you can see that the administrator is the only one with the capability manage_options. This is the one you should use. … Read more

How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?

You should be using the register_deactivation_hook and/or register_uninstall_hooks. That may be why some functions don’t work. I’d have to do some testing to be sure, but loading your method directly like WP_Plugin_Janitor::cleanup( $opt, $cpt, $tax ); seems like a pretty good way to skip over some of the WordPress load sequence or to run things … Read more

Widget HTML Display Problem

That’s a common mistake, Shortcodes should return values and not echo. Remember, the Codex is your Friend 😉 Shortcode_API#Output Output The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo – anything that is echoed will be … Read more

Auto-Populate Image After Media Upload

In the same call where the image URL is being sent to the editor, you fill up another div with an image source. Like: window.send_to_editor = function(html) { imgurl = jQuery(‘img’,html).attr(‘src’); jQuery(‘#upload_image’).val(imgurl); imgsrc=”https://wordpress.stackexchange.com/questions/82427/<img id=”upload_image” name=”upload_image” src=””+imgurl+'”>’; jQuery(‘#image-holder’).html(imgsrc); tb_remove(); } PS: this is for the Old Thickbox, not for the New 3.5 Uploader, which has very … Read more