39
votes
How to change the default registration email ? (plugin and/or non-plugin)
For 2018 and onwards users:
Since WordPress 4.9.0 there are new filters you can use for this (no need for a plugin anymore):
wp_new_user_notification_email - customise email sent to User
...
23
votes
Check if wp-login is current page
My preferred way:
if( is_wplogin() ){
...
}
code:
function is_wplogin(){
$ABSPATH_MY = str_replace(array('\\','/'), DIRECTORY_SEPARATOR, ABSPATH);
return ((in_array($ABSPATH_MY.'wp-login....
14
votes
Accepted
How do I create a password reset link?
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)...
12
votes
Accepted
How to set up User email verification after Signup?
You can use user_register hook
add_action( 'user_register', 'my_registration', 10, 2 );
function my_registration( $user_id ) {
// get user data
$user_info = get_userdata($user_id);
// ...
11
votes
What's the difference between wp_insert_user() and wp_create_user()
As per Codex
The wp_create_user function allows you to insert a new user into the
WordPress database. It uses the $wpdb class to escape the variable
values, preparing it for insertion into the ...
10
votes
Accepted
Disable user registration password email
You can intercept this email before it is sent using the phpmailer_init hook.
By default, this hook fires before any email is sent. In the function below, $phpmailer will be an instance of ...
9
votes
Placeholder text for registration form
Another simple way to do this without needing to add another script is using PHP's str_replace function.
$args = array(
'echo' => false,
);
$form = wp_login_form( $args );
//add the ...
9
votes
turn off new user registration emails
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(), ...
9
votes
Save custom user meta on registration
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', '...
9
votes
Accepted
What the user_status column?
The user_status column in the wp_users table is no longer used by WordPress core - it just hasn't been removed. It may, or may not be used in the future. Best to leave it alone...
8
votes
Accepted
How to auto login after registration?
Have you tried this?
function auto_login_new_user( $user_id ) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
wp_redirect( home_url() ); // You can change home_url() to the ...
7
votes
Check if wp-login is current page
There is a new function introduced in WordPress 6.1.0 which is is_login() which does just that.
https://developer.wordpress.org/reference/functions/is_login/
7
votes
Best way to create a user programatically
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 ...
7
votes
Accepted
How to add first name & last name to default registration form?
Add this code in functions.php
add_action( 'register_form', 'myplugin_register_form' );
function myplugin_register_form() {
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['...
7
votes
Accepted
How do I create a user using the new JSON api in 4.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 ...
7
votes
How to use the WP REST API for new user registration (sign up form)?
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 ...
6
votes
User Without Email?
Using Wordpress 4.7.2, I solved this with the following hooks:
// This will suppress empty email errors when submitting the user form
add_action('user_profile_update_errors', '...
6
votes
Get the password key when using the wp_new_user_notification_email filter
I found a function to retrieve this key : get_password_reset_key().
So now I have this code in my plugin to customize the email sent to newly registered users:
add_filter('...
5
votes
Check if wp-login is current page
More modern way to do that, it should work even when the wp-login URL is changed by plugins and when WP is in a subfolder, etc:
if(stripos($_SERVER["SCRIPT_NAME"], strrchr(wp_login_url(), '/')) !== ...
5
votes
Accepted
turn off new user registration emails
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. ...
5
votes
Accepted
How to send messages when a customer is registered
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 ...
5
votes
WordPress registration message
This message is not part of the WordPress core. I confirmed this suspicion by searching for the message within the WordPress core files. When it was not found, I then searched the message using a ...
5
votes
Accepted
BuddyPress: Allow only one email domain to register
Finally, I found the solution. Here is the code if anyone has the same issue and want to refer it.
Using Action
function wf_validate_email_domain()
{
global $bp;
$email = $bp->...
4
votes
Adding fields to the "Add New User" screen in the dashboard
You need to do 2 things.
Register fields
Save fields
Note: Below example works only for administrator user role.
1. Register fields
For Add New User use action user_new_form
For User Profile use ...
4
votes
How do I check if a post is private?
Was just looking around for this answer myself in 2020 and it seems this is a great way to do it now.
<?php if ( $wp_query->have_posts() ) : ?>
<?php while ( $wp_query->have_posts() )...
4
votes
How to allow more than one registered user to have the same email?
So unfortunately without major revisions to both code and database structure this is not possible because WordPress stores the user email in a "UNIQUE" row in the database. Just unsetting the error ...
4
votes
WordPress auto login after registration not working
Short answer - Your original function (mostly) works. This is your function edited to do what it needs to do:
function automatically_log_me_in( $user_id ) {
wp_set_current_user( $user_id );
...
4
votes
How to disable wordpress confirmation email for new users
I noticed the current answers are plugin based only.
You can use wpmu_signup_user_notification to achieve this without installing a plugin.
Add to your functions.php - this will disable user signup ...
4
votes
Create new user without password
Current versions of WP allow creation of a user without creating a password. Just leave password area blank, and verify no password if prompted.
But, best practice might be to create user with a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
user-registration × 916users × 162
login × 115
email × 63
plugins × 62
multisite × 60
user-roles × 59
php × 54
forms × 54
user-meta × 54
customization × 46
plugin-development × 39
hooks × 39
functions × 38
password × 38
woocommerce-offtopic × 33
custom-field × 28
redirect × 28
buddypress × 26
wp-login-form × 22
user-access × 21
username × 21
signup × 20
filters × 19
database × 17