check for duplicate user meta data before updating

You can check duplicate user meta using sql query.in below code if duplicate record found of other users then it will display error message and not update value. add below code in active theme’s functions.php file. function save_cust_user_profile_fields( $user_id ) { if ( isset($_POST[‘social_number’]) ) { global $wpdb; $social_number = $_POST[‘social_number’]; # query to check … Read more

Login redirect. Check user meta and redirect accordingly

woocommerce_login_redirect is similar to login_redirect and it has a users parameter. That means you don’t have to use get_current_user_id() (which was returning 0 when I tested it). Instead, replace get_current_user_id() with $user->ID;. For example: function redirect_login_to_tos($redirect, $user) { $user_id = $user->ID; $checkout_tos2 = get_user_meta($user_id, ‘checkout_tos2’, true); $checkout_tos3 = get_user_meta($user_id, ‘checkout_tos3’, true); if($checkout_tos2 != ‘agreed’ || … Read more

Run Username SQL Query from WordPress Child Theme Functions File

There are many ways you can achieve this… In your instance, as you pointed out $wpdb, here is the possible ways you can achieve this: 1. Use $wpdb::query You can run this query directly using $wpdb’s query method as: add_action(“init”, “username_query”) function username_query(){ global $wpdb; $prefix = $wpdb->prefix; $query = “UPDATE `{$prefix}wp_users` SET `user_login`= ‘new-admin-name-here’ … Read more

Using WP for user management

You might want to take a look at the REST API that comes out of the box with WordPress. Here are the docs for Users, you can register users and list/retrieve/update them https://developer.wordpress.org/rest-api/reference/users/ Here’s the information about how to authenticate to use the API (so that you can Reigister Users for instance) https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/

Change user meta value with shortcode

You made error, you made checks on the value which were null, i compile your code and made changes, here is the code it will help you. function wp_change_namecar( $atts, $content = null ) { if (is_user_logged_in()) { $user_id = get_current_user_id(); $userval =$_POST[‘cars’]; //how to define that it is the value of the form? if … Read more

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