Does the user_register change in multisite?

There is the action hook wpmu_new_user. /* * Create a user. * * This function runs when a user self-registers as well as when * a Super Admin creates a new user. Hook to ‘wpmu_new_user’ for events * that should affect all new users, but only on Multisite (otherwise * use ‘user_register’).

How to allow wordpress to create username with symbols like +

We need to add a filter to ‘sanitize_user’. Here is the sample code that will work for you. add_filter( ‘sanitize_user’, ‘tubs_sanitize_user’, 10, 3); function tubs_sanitize_user($username, $raw_username, $strict) { $new_username = strip_tags($raw_username); // Kill octets $new_username = preg_replace(‘|%([a-fA-F0-9][a-fA-F0-9])|’, ”, $new_username); $new_username = preg_replace(‘/&.?;/’, ”, $new_username); // Kill entities // If strict, reduce to ASCII for max … Read more

On user registration, if welcome mail sent, add post with new user as author

Instead of using wp_mail filter use action user_register: function fpw_new_user_post( $user_id ) { global $wpdb; update_user_meta( $user_id, $wpdb->base_prefix . ‘capabilities’, array( ‘author’ => TRUE ) ); $new_post = array ( ‘post_title’ => ‘User ‘ . get_user_by( ‘id’, $user_id )->user_login . ‘ registered @ ‘ . date( ‘Y-m-d H:i:s’, current_time( ‘timestamp’ ) ), ‘post_content’ => ‘This … Read more

How to add additional information to a user on user creation?

I’d think you’d need to hook into the user_register action, like recommended above, and then use some code similar to this: add_action(‘user_register’,’post_user_reg_redirect’); function post_user_reg_redirect( $user_id ) { if ( is_admin() ) { wp_redirect(get_edit_user_link( $user_id )); die(); } } This would check that you’re creating a user in the admin view, and then redirect to the … Read more

Checked checkbox?

I would add a hidden input field with the same name before the checkbox: <input type=”hidden” name=”email_opt_in” value=”0″ /> Because the forms are processed sequentially you would get “0” if the form was submitted, but the checkbox wasn’t checked (instead of not getting anything). Then assume the checkbox is checked if the form wasn’t submitted … Read more

Batch users creation

This is a small code I wrote to batch create generic users <?php $lock = true; //true = disabled (locked) if(!$lock) { // if not locked require_once( $_SERVER[‘DOCUMENT_ROOT’] . ‘/wp-load.php’ ); $last_registered_user = $wpdb->get_row(“SELECT ID FROM $wpdb->users ORDER BY ID DESC LIMIT 1”); $new_id = $last_registered_user->ID + 1; $limit = false; // extra lock while($new_id … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)