Disable New User Registration Email sent to WordPress admin email on 4.9.5

the function wp_new_user_notification is one of the Pluggable Functions. In the documention you can read: Pluggable functions were introduced in WordPress 1.5.1 These functions let you override certain core functions via plugins. The most up-to-date list of core functions that WordPress allows plugins to override is available at wp-includes/pluggable.php. WordPress loads the built-in functions only … Read more

Run a code only on theme activation only during first activation

What about using WordPress Options API to store a flag whether it is the first switch or not: https://codex.wordpress.org/Options_API <?php add_action(‘after_switch_theme’, ‘setup_theme_options’); function setup_theme_options () { if(get_option(‘first_theme_activation’) === false){ // Set a flag if the theme activation happened add_option(‘first_theme_activation’, true, ”, false); // stuff here only runs once, when the theme is activated for the … Read more

Generate long hashed user ID

The WordPress wp_users table uses an ID that is an auto-increment integer for unique user ID. There is no way to change that without making significant changes to the way WordPress works, and even if you do that, you will break most plugins that depend on the integer value for user ID. I don’t see … Read more

How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?

Yes, WordPress checks for duplicate emails internally, but not duplicate usernames To test this I ran this several times via wp shell: wp_create_user( ‘test’, ‘password’, ‘[email protected]’ ); The result on the second attempt was: => class WP_Error#1962 (2) { public $errors => array(1) { ‘existing_user_email’ => array(1) { [0] => string(42) “Sorry, that email address … Read more

User register hook is not working in woocomerce register form

user_register action hook is performed without any output, therefore you can’t echo anything from it. If you’re looking to debug the output from this function, dump it to the error log. function send_coupon_to_freshly_registered_user($user_id) { $user = get_user_by(‘id’,$user_id); //new line $user_email = stripslashes($user->user_email); //changed line error_log( print_r( $user_email, true ) ); // print_r the variable to … Read more