daithi-coombes / api-connection-manager

Manages connections and requests to 3rd party providers or services
0 stars 1 forks source link

Critical: manually updating user metadata #9

Closed daithi-coombes closed 11 years ago

daithi-coombes commented 11 years ago

Since the change into object oriented module's the code flow has knocked of the updating of user meta, immediately after a user is signed in using the api.

This could also be the update to wordpress 3.5 but I'm guessing a code flow change has meant that an additional call is required besides:

wp_set_current_user( $user->data->ID );
wp_set_auth_cookie( $user->data->ID );
do_action('wp_login', $user->data->user_login, $user);

A quick fix for this is to manually set the user meta in the db. The main issue is that if there are any plugins or interfaces working with the db then they will get skipped. The hack in API_Con_Mngr_Module::set_params()


            /**
             * manually update user_meta 
             */
            if($wpdb->get_row("SELECT * FROM {$wpdb->usermeta} WHERE user_id={$user_id} AND meta_key='{$option_name}'"))
                $wpdb->update($wpdb->usermeta, array(
                    'meta_value' => serialize($meta)
                ), array(
                    'user_id' => $user_id,
                    'meta_key' => $option_name
                ), array('%s'), array('%d','%s'));
            else
                $wpdb->insert($wpdb->usermeta, array(
                    'user_id' => $user_id,
                    'meta_key' => $option_name,
                    'meta_value' => serialize($meta)
                ), array('%d','%s','%s'));
            //end manual update
daithi-coombes commented 11 years ago

this issue has fixed itself since all the modules were moved to classes. My only guess as to the problem was once an array type was hit instead of an object it tripped the process.

all well now, issue closed