This is a collection of useful code snippets that can be used to achieve certain things in Passster. Some of them will be included in Passster in the future, others will stay as a code snippet.
Send an e-mail one day before a password from a list expires
This code snippet allows sending an e-mail to you (the administrator) one day before a password from a password list expires.
add_action( 'passster_compare_expiration_time', function ( $password, $difference, $password_list_id ) {
if ( $difference == 1 ) {
// prepare and send the email.
$to = 'sendto@example.com';
$subject = 'Password ' . $password . ' was used';
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
$body = 'Password ' . $password . ' from password list' . $password_list_id . ' will expire tomorrow';
wp_mail( $to, $subject, $body, $headers );
}
}, 10, 3 );
Scroll down after unlocking the content
This code snippet scrolls down the page after the content was unlocked. This is useful if you have a lot of content in the protected area and you want to show your users more of that.
add_action( 'passster_validation_success', function ( $password ) {
?>
<script>
jQuery(document).ready(function ($) {
$('html, body').animate({
scrollTop: $('#passster-scroll').offset().top('slow');
})
}
)
;
</script>
<?php
} );