Skip to content

Instantly share code, notes, and snippets.

View brocheafoin's full-sized avatar

Alexandre Simard brocheafoin

View GitHub Profile
add_action( 'um_before_new_user_register', 'require_whitelisted_email_for_signup' );
function require_whitelisted_email_for_signup( $args ) {
foreach ( [ 'yahoo.com', 'gmail.com', 'hotmail.com' ] as $domain ) {
if ( str_ends_with( $args['user_email'], '@' . $domain ) ) {
return true;
}
}
exit( wp_safe_redirect( add_query_arg( 'err', 'blocked_domain' ) ) );
}
add_action( 'um_before_new_user_register', 'require_whitelisted_email_for_signup' );
function require_whitelisted_email_for_signup( $args ) {
$user_email = $args['user_email'];
$approved_domains = array( 'yahoo.com', 'gmail.com', 'hotmail.com' );
$email_approved = false;
foreach ( $approved_domains as $domain ) {
$prefixed_domain = '@' . $domain;
if ( str_ends_with( $user_email, $prefixed_domain ) ) {
$email_approved = true;
@brocheafoin
brocheafoin / gist:6503685
Last active December 22, 2015 17:08
Making wp-content/languages/themes/ translation files accessible to Codestyling Localization via symlinks. Symlinks are made on the fly, should be update-proof. In our case, this is in a site-specific Must-Use plugin.
/* TODO
Using the 'current_screen' hook means symlinks will be recreated *every time* a Codestyling Localization page is called.
A better solution would be to store themes' versions in a site_option and run this only when installed versions are higher than what we have in our site_option (i.e. an update has been made). See here:
http://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
*/
add_action( 'current_screen' , 'uneq_cs_translations' );
function uneq_cs_translations( $current_screen ) {
/* Re/Create symlinks when visiting Codestyling page */