Last active
November 1, 2024 13:23
-
-
Save wpo365/23c908970a9fddaf0309731c039362c6 to your computer and use it in GitHub Desktop.
Examplary plugin that demonstrates how a developer may hook into the "wpo365/user/user_login" filter in order to customize the WordPress username when WPO365 creates a new user. The filter "wpo365/user/user_login" must be added to WordPress using a custom plugin. Hooking into this filter - for example - in your (child) theme's functions.php will…
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 | |
/** | |
* Plugin Name: WPO365 | USER-LOGIN | |
* Plugin URI: | |
* Description: Examplary plugin that demonstrates how a developer may hook into the "wpo365/user/user_login" filter in order to customize the WordPress username when WPO365 creates a new user. | |
* Version: 0.1 | |
* Author: marco@wpo365.com | |
* Author URI: https://www.wpo365.com | |
*/ | |
// Prevent public access to this script | |
defined('ABSPATH') or die(); | |
/** | |
* The filter "wpo365/user/user_login" must be added to WordPress using a custom plugin. | |
* Hooking into this filter - for example - in your (child) theme's functions.php will | |
* add the filter after it has been triggered. | |
*/ | |
add_filter('wpo365/user/user_login', function ($user_login) { | |
$_user_login = stristr($user_login, '@', true); | |
$_user_login = sanitize_user($_user_login); | |
$_user_login = sprintf('%s-%s', time(), $_user_login); | |
return $_user_login; | |
}, 10, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment