Re: Plugin update first_name, last_name in wp_usermeta on activation
With this I get four missing argument errors again. Why?
function synchro_wp_usermeta($key, $user_id, $password, $meta) {
global $bp, $wpdb;
$fullname = $wpdb->get_var("SELECT meta FROM $wpdb->signups WHERE activation_key = %s", $key);
echo $fullname;
$space = strpos( $fullname, ' ' );
if ( false === $space ) {
$firstname = $fullname;
$lastname = '';
} else {
$firstname = substr( $fullname, 0, $space );
$lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
}
update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
}
add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 4);