Created
March 4, 2020 20:35
-
-
Save mgibbs189/f6e2173f5f710c63331cee86fa9cbb3d to your computer and use it in GitHub Desktop.
FacetWP - convert User Email into an md5 hash
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 | |
/** | |
* Add to your (child) theme's functions.php | |
* | |
* We've added a layout builder item (named "email-md5"), based on the "User Email" field, and set to Hidden | |
* We've also added a new HTML item with the following content: | |
* | |
* <img src="https://www.gravatar.com/avatar/{{ email-md5 }}?s=200" /> | |
* | |
* This generates the user's profile image (based on Gravatar) | |
*/ | |
add_filter( 'facetwp_builder_item_value', function( $value, $item ) { | |
if ( 'email-md5' == $item['settings']['name'] ) { | |
$value = md5( $value ); | |
} | |
return $value; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment