Created
February 27, 2015 18:36
-
-
Save adamcapriola/b839381e9894c89699b2 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 | |
/** | |
* Add user meta to signify the user has just logged in | |
* | |
*/ | |
add_action( 'wp_login', 'ac_fresh_login', 10, 2 ); | |
function ac_fresh_login( $user_login, $user ) { | |
update_user_meta( $user->ID, 'fresh_login', 1 ); | |
} | |
/** | |
* One-time Discourse SSO iframe | |
* | |
*/ | |
add_action( 'wp_footer', 'ac_discourse_sso_iframe' ); | |
function ac_discourse_sso_iframe() { | |
// Only show iframe on first page the user hits after logging in | |
$fresh_login = get_user_meta( get_current_user_id(), 'fresh_login', true ); | |
if ( $fresh_login == 1 ) { | |
echo '<iframe src="http://discourse.example.com/session/sso" width="0" height="0" tabindex="-1" title="Discourse SSO" style="display:none" hidden>' . "\n"; | |
delete_user_meta( get_current_user_id(), 'fresh_login' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment