28

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 ...


18

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

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->...


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:...


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 ...


10

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 '...


10

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 ...


10

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).


10

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() ? ...


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

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

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

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 ...


7

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 ...


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 ...


7

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 ...


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

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. ...


6

You should read the codex page re wp_create_user. You don't describe the context in which your code runs. You shouldn't need all those require_once calls. Anyhow, in this line wp_new_user_notification ( testuser8,null,'both' ); what is testuser8 ? It's not a variable, it's not a string, it's just some text that probably throws an error. Try: $user_id =...


6

hopefully you've found the answer already. Here's our solution, for your reference. :D The following code should add User Registration via REST API to your WordPress Website. It supports Registration of 'subscriber' and 'customer'. Source code also available on Github. Add it to your function.php add_action('rest_api_init', 'wp_rest_user_endpoints'); /** ...


6

You have to trigger the following hooks: user_register personal_options_update edit_user_profile_update add_action('user_register', 'addMyCustomMeta'); add_action('personal_options_update', 'addMyCustomMeta' ); add_action('edit_user_profile_update','addMyCustomMeta' ); function addMyCustomMeta( $user_id ) { 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

Generic Pluggable Approach for WordPress < 4.6 (See @birgire's Answer for > 4.6) Pluggable functions are one of the more depressing relics of WordPress's past and come with a slew of intricacies. That directly modifying the core file (which is entirely inadvisable, as @Jarmerson mentioned in the comments) did not work makes me suspect that another plugin ...


5

If you're talking about Wordpress user registration, you want to start by reading about the User Register hook: https://codex.wordpress.org/Plugin_API/Action_Reference/user_register Then your code would be something like this which will automatically fire each time a user registers on the site: add_action('user_register','send_sms'); function send_sms($...


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