Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created May 15, 2015 11:16
Show Gist options
  • Save gicolek/9561eb5edfb6eb3718fb to your computer and use it in GitHub Desktop.
Save gicolek/9561eb5edfb6eb3718fb to your computer and use it in GitHub Desktop.
Gravity Forms Password Recovery Shortcode
<?php
add_shortcode( 'verify_user_pass', 'wp_doin_verify_user_pass' );
/**
* Shortcode which is used to cover Gravity Forms shortcode. It will not render the password
* reset form in case of invalid pass.
*
* @shortcode verify user pass
*/
function wp_doin_verify_user_pass($args, $content = null) {
// lets make usage of the custom global variable to fetch
// the values from the safe / cookie validation functions
global $gf_reset_user;
// start output buffering for a more visually appealing output
ob_start();
if ( !$gf_reset_user || is_wp_error( $gf_reset_user ) ) {
if ( $gf_reset_user && $gf_reset_user->get_error_code() === 'expired_key' )
echo '<h2 class="error">The key has expired.</h2>';
else
echo '<h2 class="error">The key is invalid</h2>';
} else {
echo '<h2>Please update your password below.</h2>';
echo do_shortcode( $content );
}
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment