Customizing WP tables or adding new ones?

You should avoid adding new tables or customising the existing tables to add fields for users. If you want to store a phone number etc, do it using user meta: add_user_meta( $user_id, ‘riccardo_phone_number’, ‘0123-456-7890’ ); …. $phone_number = get_user_meta( $user_id ); User meta is a key and a value with a post ID in the … Read more

Add profile field (usermeta) to Add New User

To add data to the form at user-new-php, I believe you want the user_new_form hook. Unfortunately, it is marked “@since 3.7.0” so it isn’t in the stable release yet. I am tempted to tell you to hack it into your site in exactly the place that it will soon appear, but that would be wrong. … Read more

wp_get_current_user in custom file returns 0

The problem with your code is that you want to get current user to early. wp_get_current_user is using global current_user variable. But this variable isn’t set from the beginning. And if you want to use this function straight in the script file, then it’s to early. You should wait for init action to get current … Read more

User meta to post

I think at leasts one approach to this would be the following process: – get all posts by authors – foreach post: – get the author user_meta genere – update the post_meta with that value I have not tested any of the code below, so I wouldn’t copy/paste. But hopefully reading through it will get … Read more

Check if WP_User_Query ‘include’ is empty

I think the problem here is that in the process of violating this rule, you’ve created confusion and problems: do 1 thing per statement, 1 statement per line Coupled with another problem: Passing arrays to the APIs which get stored as serialised PHP ( security issue ) And another: Always check your assumptions it ignores … Read more

Validating a new user registration field

After examining the code and much trial and error, I have a solution: There is a filter – user_profile_update_errors – that is called in the file wp-admin/includes/user.php just after WordPress does it’s own input validation. This filter allows plugins to return their own errors by adding them to a referenced WP_Error class. If any errors … Read more

how to get specific fields from get_user_meta()

The function’s arguments are as follows: user ID, custom field name (meta key), data return method (optional). So if you wanted to grab data in usermeta with the key of ‘member_zip_code’, you would run: get_user_meta( $user_id, ‘member_zip_code’, true ); Alternatively, in your prior method, you could grab the additional data like this: $data = get_user_meta … Read more

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