Created
September 17, 2016 14:26
-
-
Save stompweb/f75e9d2f9036a6a618c6e4d2a9a5c68d to your computer and use it in GitHub Desktop.
Backdrop Test
This file contains 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 exp_add_notifications( $post_id, $post ) { | |
if ( 'auto-save' == $post->post_status || 'auto-draft' == $post->post_status ) { | |
return; | |
} | |
$message = get_the_title( $post_id ) . ' was added.'; | |
$task = new \HM\Backdrop\Task( 'exp_send_notifications', $message ); | |
$task->schedule(); | |
} | |
add_action( 'publish_topic', 'exp_add_notifications', 10, 2 ); | |
function exp_send_notifications( $message ) { | |
$users = new WP_User_Query( array( 'role' => 'Subscriber' ) ); | |
if ( ! empty( $users ) ) { | |
foreach ( $users as $user ) { | |
exp_add_notification( $user->ID, $message ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment