Last active
December 2, 2019 11:31
-
-
Save avillegasn/503fb8bc1112bbd3024e9753e4d26a29 to your computer and use it in GitHub Desktop.
Creating a function
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 | |
/** | |
* Sends and email when a post is published. | |
* | |
* Sends and email using wp_mail standard WordPress function including data about | |
* the post being published. | |
*/ |
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 | |
/** | |
* Sends and email when a post is published. | |
* | |
* Sends and email using wp_mail standard WordPress function including data about | |
* the post being published. | |
* | |
* @param int $ID Post ID. | |
* @param WP_Post $post Post object. | |
*/ | |
function nelio_notify_on_post_published( $ID, $post ) { | |
// Assemble the message. | |
$message = 'Hi, a new post has been published. Here is the content:'; | |
$message .= $post->post_content; | |
// Assemble the subject. | |
$subject = '[New Post] ' . $post->post_title; | |
// Send the notification. | |
wp_mail( '[email protected]', $subject, $message ); | |
}//end nelio_notify_on_post_published() | |
add_action( 'publish_post', 'nelio_notify_on_post_published', 10, 2 ); |
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 | |
/** | |
* Sends and email when a post is published. | |
* | |
* Sends and email using wp_mail standard WordPress function including data about | |
* the post being published. | |
* | |
* @param int $ID Post ID. | |
* @param WP_Post $post Post object. | |
*/ | |
function nelio_notify_on_post_published( $ID, $post ) { | |
// Assemble the message. | |
$message = 'Hi, a new post has been published. Here is the content:'; | |
$message .= $post->post_content; | |
// Assemble the subject. | |
$subject = '[New Post] ' . $post->post_title; | |
// Send the notification. | |
wp_mail( '[email protected]', $subject, $message ); | |
}//end nelio_notify_on_post_published() |
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 | |
/** | |
* Sends and email when a post is published. | |
* | |
* Sends and email using wp_mail standard WordPress function including data about | |
* the post being published. | |
* | |
* @param int $ID Post ID. | |
* @param WP_Post $post Post object. | |
*/ | |
function nelio_notify_on_post_published( $ID, $post ) { | |
}//end nelio_notify_on_post_published() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment