Created
June 9, 2023 12:52
-
-
Save nicmare/ef8b37a89da4b4b70782a06ca9e00adc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function set_media_folder($pid = ""){ | |
| if(empty($pid)) return; | |
| if(get_post_type($pid) == "attachment"){ | |
| if(($path = get_attached_file($pid)) && str_contains($path,"nsl_avatars")) { | |
| if ( $term_avatars = get_term_by( 'slug', 'avatare', 'happyfiles_category' ) ) | |
| wp_set_object_terms( $pid, $term_avatars->term_id, 'happyfiles_category' ); | |
| wp_update_post([ | |
| 'ID' => $pid, | |
| 'post_title' => __("User-Avatar","myb") | |
| ]); | |
| } | |
| } | |
| } | |
| add_action('add_attachment','set_media_folder',30); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment