Last active
October 3, 2015 22:45
-
-
Save AaronRutley/2e99f17df614c74ef95c to your computer and use it in GitHub Desktop.
ar_user_login.php
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 | |
// ar_user_login : on WordPress login, post a message to slack | |
function ar_user_login($user_login) { | |
// get the user info | |
$user = get_user_by('login',$user_login); | |
// get the user ID | |
$user_id = $user->ID; | |
// get the user's slack username (this is custom meta) | |
$user_slackname = get_user_meta($user_id, 'slack_username',true); | |
// get the current site url | |
$site_url = get_bloginfo('url'); | |
// prepare a message to be posted to slack | |
$message = '@'.$user_slackname.' just logged in to '.$site_url; | |
// post the message to slack in the general channel | |
ar_post_to_slack($message,'#general','WordPress bot',':taco:'); | |
} | |
add_action('wp_login', 'ar_user_login', 99, 2); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment