If you want login a user by user ID without password then using the following code wp_clear_auth_cookie(); wp_set_current_user($userID); wp_set_auth_cookie($userID, true, false); update_user_caches($userID); Have any doubt, then comment here!
You can try to add some class for the field media_gallery_content_save and then to validate it as you check it to be != []. For example in app/design/adminhtml/default/default/template/catalog/product/helper/gallery.phtml replace this:
<input type="hidden" id="<?php echo $_block->getHtmlId() ?>_...