Skip to content

Instantly share code, notes, and snippets.

@adamcapriola
Created February 27, 2015 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamcapriola/b839381e9894c89699b2 to your computer and use it in GitHub Desktop.
Save adamcapriola/b839381e9894c89699b2 to your computer and use it in GitHub Desktop.
<?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