Custom Text in Media Uploader in a Theme Options Page

This is a short version of what I do in one of my plugins. I copied this behavior from the plugin Advanced Custom Fields (some versions ago, donnow how it proceeds now). 1) When calling the thickbox, add a custom query var (mtt_type in this case): tb_show(‘{$mtt_title}’, ‘media-upload.php?type=image&mtt_type=image&TB_iframe=true’); 2) Print scripts in media-upload.php to modify … Read more

Problem uploading different files as custom fields with front end post form

For starters, the ‘post_category’ argument only accepts category ID’s, so you will have to find that through your database, or through get_category_by_slug: $cat = get_category_by_slug( ‘music’ ); $cat_id = $cat->term_id; Secondly, look at your wp_handle_upload() section. You are passing $file[‘file’] in both cases, where ‘file’ is not the name of either of your upload fields. … Read more

image URL changed in wordpress

Using WordPress plugin – Search And Replace This is simple WordPress plugin, Does database query to replace any content. This plugin can be used to replace a string ( say – localhost:8888 ) with a new one ( domain.com ) . Direct updating MySQL Database – Or, If you’ve access to MySQL Server you can … Read more

Multisite missing tmp folder error while uploading

As this sounds like an existing WordPress setup that ‘was’ working and now ‘is not’ working then check a couple of things: 1. have you recently moved server? or who else has changed anything on your server such as: – file permissions for the WordPress folder – have these change? – php.ini or .htaccess files … Read more

How to change image’s author via a function when using GravityForms uploader? [closed]

add_action(“gform_user_registered”, “image_author”, 10, 4); function image_author($user_id, $config, $entry, $user_pass) { $post_id = $entry[“post_id”]; $args = array( ‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’ ); $attachments = get_posts($args); if($attachments) : foreach ($attachments as $attachment) : setup_postdata($attachment); $the_post = array(); $the_post[‘ID’] = $attachment->ID; $the_post[‘post_author’] = $user_id; wp_update_post( $the_post ); endforeach; endif; }

How to delete file uploaded by Plupload

To delete a file from the file system, you can use something like this attached to an AJAX hook that is called by jQuery: function ajax_remove_image() { check_ajax_referer( ‘image_removal’, ‘image_removal_nonce’ ); if ( ! $_POST[ ‘confirm’ ] ) exit( ‘false’ ); $uploads = wp_upload_dir(); $upload_dir = $uploads[ ‘path’ ]; $file = strpos( $_POST[ ‘file’ ], … Read more