A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
23

Firstly, you need to add the following capabilities to the Doctor and Receptionist role: list_users edit_users create_users delete_users Now we can get to work with controlling which users they can create/edite/delete. Let's start with a "helper" function that will return which roles a user is allowed to edit: /** * Helper function get getting roles that ...


17

user_new_form is the hook that can do the magic here. function custom_user_profile_fields($user){ ?> <h3>Extra profile information</h3> <table class="form-table"> <tr> <th><label for="company">Company Name</label></th> <td> <input type="text"...


13

I had the same need and created the following hack: <?php function hack_add_custom_user_profile_fields(){ global $pagenow; # do this only in page user-new.php if($pagenow !== 'user-new.php') return; # do this only if you can if(!current_user_can('manage_options')) return false; ?> <table id="...


13

DB Access layer & deleting rows WordPress uses the wpdb class to manage access to the database layer using the global $wpdb. The class provides a method named delete() to delete rows from tables: $wpdb->delete( $table, $where, $where_format = null ); Multisite tables & activation keys WordPress has some MU specific tables, where one is {$wpdb-&...


11

Absolutely YES, you can achieve this. Rule 1: WordPress requires a username. We must provide a username. Rule 2: Don't edit WordPress core code. We can achieve this by hiding username field, get email and store it as username. Step-1: Remove Username textfield add_action('login_head', function(){ ?> <style> #registerform > p:...


11

You kind of answered the question yourself already, Create a function that will create the 3 posts ex: function create_new_user_posts($user_id){ if (!$user_id>0) return; //here we know the user has been created so to create //3 posts we call wp_insert_post 3 times. // Create post object $...


10

The nicename is (usually) just a sanitized version of the username. It's suppose to be 'nice' in the sense that it is the 'nicename' that is used as a slug, for example: www.yoursite.com/author/my-nice-name/ will take you to the archive of the author with nicename 'my-nice-name'. The documentation simply describes it as A string that contains a nicer ...


10

None. The whole source of wp_create_user() is: function wp_create_user($username, $password, $email = '') { $user_login = esc_sql( $username ); $user_email = esc_sql( $email ); $user_pass = $password; $userdata = compact('user_login', 'user_email', 'user_pass'); return wp_insert_user($userdata); } It just calls insert version almost ...


9

get_current_user_id() give you the user id of the logged in user. And that is: you. You have to get all users: <?php $users = get_users(); foreach( $users as $user ) { $udata = get_userdata( $user->ID ); $registered = $udata->user_registered; printf( '%s member since %s<br>', $udata->...


9

You're looking in the wrong place. When a user first attempts to register, their username and email is processed and sanitized inside the register_new_user() function in wp-login.php. This is where you want to do your filtering. Before the user is created, WordPress will pass the sanitized user login, email address, and an array or errors through the '...


9

This is similar to Shawn H's answer but is more effective for me. I already had registrations disabled, but bots still show up constantly to try anyway. My goal was to completely kill all requests to the registration form to avoid the load on my server (and mess in my logs) caused by bots trying to register, so this solution sends a 403 denied error to ...


9

To accomplish user activation process you need to do following steps: after create new user add a custom user field which indicates that this user has to activate his account send an email with activation code, provide a link in this email to a page where user will be activated implement activation page when user attempts to log in check if that custom user ...


9

You can check it very easily with the help of get_option. Here is a simple code for checking if user registration is allowed. if ( get_option( 'users_can_register' ) ) { // Your custom code or message to display if user registration is allowed. } get_option( 'users_can_register' ) returns boolean true (1) or false (0).


8

Ok, first of all, I feel like an idiot, although in my defense most of the articles that talk about this don't mention a very crucial detail in making this work. The answer is that you need to set permission for at least one admin in the database. This info can be found in the Codex here: http://codex.wordpress.org/Editing_wp-config.php#...


8

If you want a quick solution for deleting a signup in the database for a specific user, this should do what you want: /** * Delete a row in the signups table for a given username. * * @param string $user_login Username. * @return bool Whether the signup row was successfully deleted. */ function delete_activation_key_by_user( $user_login ) { global $...


8

After much research, I finally turned to examining the WordPress core file wp_login.php hoping that WP would show how they do it in a non-obtuse manner. From the information around line 331 (WP 4.6.1), I put together the following code. <?php global $gw_activate_template; extract( $gw_activate_template->result ); $url = is_multisite() ? ...


7

How about using get_users()? You probably don't even need parameters for it, default behavior should be just what you're looking for.


7

This certainly can be done, but it requires some work. I am developing a pretty complex plugin for a client, and I plan to expand on it and make it available publicly when it is ready. Telling you everything would take ages, so I will just give you some pointers on how you can achieve what you are aiming for. Make a page called "Profile" and use a custom ...


6

What you are best off doing is hooking into user_register and from there updating the user options you want them set to. Below is an example of disabling the admin bar for new users: add_action("user_register", "sc_set_user_admin_bar_false_by_default", 10, 1); function sc_set_user_admin_bar_false_by_default($user_id) { update_user_meta( $user_id, '...


6

There are two ways to customize the default avatar: Add a new default avatar to Settings/Discussion. Change the output of get_avatar(). Let’s start with the first option; this processes slightly faster. Add a new default avatar to Settings/Discussion There is a filter 'avatar_defaults'. You can add more avatars here. You get an array of default images ...


6

Do you think this will be safe? Maybe. Two issues. You also need to make sure the key isn't guessable. No incrementing numbers. You can use something like wp_generate_password to get some psuedo random characters. Use a random "salt" plus the user's email and sign up time or uniqid and you stand a pretty good chance of ensuring uniqueness (see below) and ...


6

Actually I found this to be more strait forward and simpler: //add columns to User panel list page function add_user_columns($column) { $column['address'] = 'Street Address'; $column['zipcode'] = 'Zip Code'; return $column; } add_filter( 'manage_users_columns', 'add_user_columns' ); //add the data function add_user_column_data( $val, $...


6

Approach for WordPress 4.6+ Check out the patch in ticket #36009 that was merged into WordPress version 4.6. It adds the 'user' option for the $notify input parameter of wp_new_user_notification(), to skip sending those emails to the admin. How it works The register_new_user() function contains this part: do_action( 'register_new_user', $user_id ); The ...


6

The REST API included in WordPress doesn't actually have authentication built into it. If you do normal authentication in WordPress by logging in, then your browser will receive a set of cookies. If you send those cookies along with your request, then that will authenticate you to perform the actions in question. If you need to add authentication for an ...


5

The codex page for wp_insert_user() lists all the values that it accepts. comment_shortcuts, and show_admin_bar_front will all need to be set with update_user_meta(). To handle wp_user_level and wp_capabilities you will need to use WP_User. You can use $new_user_user_id (long var name lol) for both WP_User and update_user_meta()


5

Use wp_redirect() and admin_url() to redirect the user to his profile page if the custom buddypress user meta data isn't completely filled. From another answer, I've seen that there's the following function: bp_get_profile_field_data(). So you can easily build a template tag, that gives you either the full buddy user meta data set, or simply a FALSE back. ...


5

If wp_generate_password() was called with the third parameter $extra_special_chars = true a space might be part of the password: function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; if ( $special_chars ) $chars .= '!@#$%^...


5

You'll need three hooks: 1: user_register This is for when the user is created via the admin back-end. The username will be available via $_POST['user_login'] and the password will be available via $_POST['pass1']. 2: edit_user_profile_update This is for when the password is updated on the profile page by the user or admin. The username will be available ...


5

Unfortunately, this just isn't possible. There are three occasions where WordPress performs this check: When you click 'save' on the edit user screen( https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/user.php#L157 ) When a user is registered ( https://github.com/WordPress/WordPress/blob/master/wp-includes/user.php#L2023 ) When a user is ...


5

Yes, you can Change email address by using wp_mail function. You can check this how to do this http://www.butlerblog.com/2011/07/14/changing-the-wp_mail-from-address-with-a-plugin/ Use this plugin for user management it supports email address when new user registers https://wordpress.org/plugins/wp-members/ Use this code in your functions.php file. ...


Only top voted, non community-wiki answers of a minimum length are eligible