Gallery Post Create Form (Advanced Forms) (reference)

if(is_user_logged_in()) { $current_user = wp_get_current_user(); $current_user_id = $current_user->ID; $current_user_login = $current_user->user_login; $current_user_display_name = $current_user->display_name; $current_user_first_name = get_user_meta( $current_user_id, ‘first_name’, true ); $current_user_last_name = get_user_meta( $current_user_id, ‘last_name’, true ); } ?>Continue reading

Restrict Upload File Types (reference)

add_filter(‘upload_mimes’,’restrict_mime’); function restrict_mime($mimes) { //global $current_user; //get_currentuserinfo(); // change users in list //$users = array( //”ryan”, //”steven”, //”larry”, //”jerry” //); //if (!in_array($current_user->user_login, $users)) { if ( !current_user_can( ‘manage_options’ ) ) { $mimes = array( ‘jpg|jpeg|jpe’ => ‘image/jpeg’, ‘webp’ => ‘image/webp’,…Continue reading

Upload Directories Per User (reference)

function per_user_upload_dir( $original ){ $modified = $original; if( ( isset( $_REQUEST[‘action’] ) && ( “um_resize_image” == $_REQUEST[‘action’] || “um_imageupload” == $_REQUEST[‘action’] ) ) || isset( $_REQUEST[‘um_action’] ) ){ return $original; } elseif ( is_user_logged_in() && !current_user_can( ‘manage_options’ ) ) {…Continue reading

Per User ACF Upload Directory (reference)

add_filter(‘acf/upload_prefilter/name=gallery_post_featured_image’, ‘per_user_upload_prefilter’); function per_user_upload_prefilter($errors) { // in this filter we add a WP filter that alters the upload path add_filter(‘upload_dir’, ‘per_user_upload_dir’); return $errors; } // second filter function per_user_upload_dir($uploads) { // here is where we alter the path $current_user =…Continue reading

Delete User with Disapprove

add_action(“um_after_user_status_is_changed”,”um_011822_delete_account_on_rejection”, 10, 2); function um_011822_delete_account_on_rejection( $status, $user_id ) { if( “rejected” == $status ) { // Disable delete notification on rejection and deletion UM()->user()->send_mail_on_delete = false; if ( is_multisite() ) { if ( ! function_exists( ‘wpmu_delete_user’ ) ) { require_once(…Continue reading

Automatically Delete Woocommerce Images After Deleting a Product

// Automatically Delete Woocommerce Images After Deleting a Product add_action( ‘before_delete_post’, ‘delete_product_images’, 10, 1 ); function delete_product_images( $post_id ) { $product = wc_get_product( $post_id ); if ( !$product ) { return; } $featured_image_id = $product->get_image_id(); $image_galleries_id = $product->get_gallery_image_ids(); if( !empty(…Continue reading