Automatically Notify Your Members on New Posts
Tento článek (nebo jeho část) je převzat z externího zdroje. Je tedy slušností jej uvést včetně případného autora.
Send an email to all registered users when a post is published. Simply place this code into your functions.php file.
CODE SNIPPET:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php function email_members($post_ID) { $wp_user_search = new WP_User_Query( array( 'fields' => array('user_email') ) ); $usersarray = $wp_user_search->get_results(); $arrUsers = array (); for ($arr = $usersarray, $mU = count ($arr), $iU = 0; $iU < $mU; $iU++) { $arrUsers[] = $arr[$iU]->user_email; } // for $users = implode(",", $arrUsers); mail($users, "New post notification : " . get_bloginfo('name') , "A new post has been published on " . get_bloginfo('siteurl') ); return $post_ID; } add_action('publish_post', 'email_members'); ?> |
Napsat komentář