Restrict certain roles registrations by domain

You’ll want to checkout the registration_errors filter. Make sure the role is being posted within the particular registration form. Instead of conditionally adding your action you have to check within the filter if role and email are valid. add_action( ‘registration_errors’, ‘wpse_248123_registration_errors’ ); function wpse_248123_registration_errors( $sanitized_user_login, $user_email, $errors ) { if ( empty( $_POST[‘role’] ) ) … Read more

Select dropdown with 2 choices from foreach

You can use in_array to check if the name of the role is either customer or shop_manager add_action(‘register_form’, ‘myplugin_register_form’); function myplugin_register_form() { global $wp_roles; echo ‘<select name=”role” class=”input”>’; foreach ($wp_roles->roles as $key => $value): if ( in_array( $key, array(‘customer’, ‘shop_manager’) ) ) echo ‘<option value=”‘ . $key . ‘”>’ . $value[‘name’] . ‘</option>’; endforeach; echo … Read more

Add custom Date column to “All Users” admin panel in WP

This should be it <?php function new_contact_methods( $contactmethods ) { $contactmethods[‘signupdate’] = ‘Date’; return $contactmethods; } add_filter( ‘user_contactmethods’, ‘new_contact_methods’, 10, 1 ); function new_modify_user_table( $column ) { $column[‘signupdate’] = ‘Date’; return $column; } add_filter( ‘manage_users_columns’, ‘new_modify_user_table’ ); function new_modify_user_table_row( $val, $column_name, $user_id ) { $user = get_user_by( ‘id’, $user_id ); $date_formatted = new DateTime($user->user_registered); switch … Read more

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