Tag Info

Hot answers tagged

9

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


6

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


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


5

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


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

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


4

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


4

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


4

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


4

The following untested code should get you started. Basically you add a display target on your form, add some javascript to add the validation when the user leaves the username field, and the server-side code to enqueue the javascript, and register the ajax actions. Let me know what breaks, as I'm sure this will not run out of the box. [!--HTML to add to ...


4

I would definitely not advise you to enforce this policy. For example, I can enumerate through your list of authors by simply entering yoursite.com/?author=1, yoursite.com/?author=2, etc into my browser. This will take me to your author pages. If your users were savvy enough, they might have set their public display name in Users/Your Profile to something ...


3

This is not a WooCommerce question. Once the user is registered you use WordPress functions to verify whether the user is logged in and to retrieve the user's info. Assuming you are saving the user info correctly, then this should show a user's first name to the user, and a generic message to a non-logged-in user. if ( is_user_logged_in() ) { ...


3

Take a look at the WordPress Codex: Customizing The Registration Form Theme and plugin developers can customize WordPress's built-in user registration page through the use of hooks. Customizing the registration form involves utilizing the following three hooks: register_form Allows rendering of new HTML form elements. ...


3

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 logs in check if that custom user field ...


3

WordPress's usernames are exposed in several public facing places even when choosing a separate display name when making a post. As for privacy/spam that's up to you and your users. You can enable email logins using a plugin like WP Email Login that I think still uses the "username" publicly, so that might be a good solution. I'm not 100% sure it does ...


3

I workaround is available by using the user_new_form_tag which resides inside the user-new.php page's form starting tag. It's in the end so if you output HTML after that you just need to begin the output with > and remove the last outputted > of your own code. As in: function add_new_field_to_useradd() { echo "><div>"; // Note the first ...


3

Proper hooks for login and register actions: <?php function custom_plugin_hooks() { add_action( 'login_form', 'custom_plugin_form_inputs' ); add_filter( 'authenticate', 'custom_plugin_login_check', 100, 3 ); add_action( 'register_form', 'custom_plugin_form_inputs' ); add_action( 'register_post', 'custom_plugin_registration_check', 100, ...


3

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


3

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


3

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


3

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


3

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


3

You can use user_register add_action('user_register', 'wpse42506_user_register', 10, 3); function wpse42506_user_register( $user_ID ) { // do stuff here } If you want to just use the user information, you can use get_userdata http://codex.wordpress.org/Function_Reference/get_userdata If you need more control, you can initiate a new WP_User ...


3

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


3

Basically, this is a programming pattern for namespacing code within a WordPress plugin. Typically, you can only have one function called init() in a program, but more than one author will try to use that name. Placing function names in a class is a way around this limitation. For example: class Towfiq_Person { static function on_load() { } ...


3

Here is a function I've Used Before: function registration_form_wpa95139(){ if (is_user_logged_in()) return; ?> <div class="Registration"> <div id="register-form"> <div class="title"> <h1><?php _e('Register your Account'); ?></h1> <span><?php ...


2

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


2

Since you mentioned wordpress.com, I assume you're thinking of a blogging network. You can do that using WordPress Multisite. Here's how to enable it: http://codex.wordpress.org/Create_A_Network


2

I had to implement this for a client site and ended up creating my own system. I hash the email and date created timestamp and store it as a key in usermeta, then i email that key to the user's email in the form of a link. The link points to a page where I've created a rewrite rule and added my own query var so I can make nice site.com/authorize/{key} ...


2

Both modifying the fields and the styling of the user registration (as well as login, lost password, etc. pp.) page can be done programmatically as well as using plugins. The latter obviously being the much simpler way of achieving quick results. While I'm all for control and doing things on our own, in this case there really is no need to, since excellent ...



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