Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Europe/Kyiv (GMT+02:00)

This topic contains 12 replies, has 0 voices.

Last updated by Andrey 1 day, 13 hours ago.

Assisted by: Andrey.

Author Posts
February 13, 2025 at 4:32 pm #16703803

janineI

Background of the issue:
I was trying to update the WPML plugin using your tool while using WordPress 5.7.

Symptoms:
I encountered a PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function WPML_User_Language::update_user_lang_from_login(), 1 passed in /data/sharedstorage/brandspecifiek.nl/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php on line 17 and exactly 2 expected in /data/sharedstorage/brandspecifiek.nl/wp-content/plugins/sitepress-multilingual-cms/classes/user-language/class-wpml-user-language.php:259. Additionally, there were multiple PHP Notices about undefined indexes in the theme's header.php file.

Questions:

February 13, 2025 at 4:47 pm #16703841

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for contacting WPML support.

Have you considered updating to the latest version of WordPress? Your current version is quite outdated, and updating will allow you to benefit from the latest bug fixes and improvements.

February 13, 2025 at 5:14 pm #16703919

janineI

i have considered but rather wait .
since with any massive update there are more drawbacks.

February 14, 2025 at 9:53 am #16705584

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for your feedback. I encourage you to update everything, as the issue may no longer occur with the latest version of WordPress.

Could you please share the full log of the errors? Are you using any custom functions for the login? Additionally, are you using the latest version of your theme?

I have enabled debug information for this support ticket. Please refer to this link for instructions on how to retrieve this information from your site and provide it to us: http://wpml.org/faq/provide-debug-information-faster-support/.

February 16, 2025 at 7:42 pm #16711238

janineI

after updating to wordpress 6.7.2 its not resolved the issue.

And no we are not using anything fancy with the login.

The problem is that there are only 1 value being submitted and not 2.

February 16, 2025 at 7:47 pm #16711244

janineI

[13-Feb-2025 16:18:01 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function WPML_User_Language::update_user_lang_from_login(), 1 passed in /data/sharedstorage/brandspecifiek.nl/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/functions.php on line 17 and exactly 2 expected in /data/sharedstorage/brandspecifiek.nl/wp-content/plugins/sitepress-multilingual-cms/classes/user-language/class-wpml-user-language.php:259
Stack trace:

February 18, 2025 at 10:05 am #16717912

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for your feedback.

Have you attempted to manually update WPML by downloading the latest versions from wpml.org?

To assist you more effectively, I need to request temporary access to your site (both wp-admin and FTP). Please provide access to a test site where the issue can be replicated if possible. You will find the necessary fields below the comment area when you log in to respond. This information is private and can only be seen by you and me.

Additionally, please provide the steps to replicate the issue.

February 18, 2025 at 4:23 pm #16720194

janineI

before i can give you access i have updated the plugin using your installer.
Also we have a firewall setup so i will need your ip to whitelist to allow ftp access.

February 19, 2025 at 2:34 pm #16725275

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

I have a dynamic IP address. Currently, it is 37.139.164.94. The following message is private. If possible, I suggest testing the problem with only WPML enabled and the default theme as well.

February 19, 2025 at 3:10 pm #16725507

janineI

<?php
if ( isset( $_POST['login_Sbumit'] ) ) {

// Prepare credentials array for wp_signon
$creds = array();

// Get and sanitize the user login (username or email)
if ( isset( $_POST['userEmail'] ) ) {
$creds['user_login'] = stripslashes( trim( $_POST['userEmail'] ) );
} else {
$creds['user_login'] = '';
}

// Get and sanitize the password
if ( isset( $_POST['userPass'] ) ) {
$creds['user_password'] = stripslashes( trim( $_POST['userPass'] ) );
} else {
$creds['user_password'] = '';
}

// Check if 'rememberMe' is set and sanitize it
$creds['remember'] = isset( $_POST['rememberMe'] ) ? sanitize_text_field( $_POST['rememberMe'] ) : '';

// Determine where to redirect the user after login
$redirect_to = esc_url_raw( $_POST['redirect_to'] );
if ( empty( $redirect_to ) ) {
$redirect_to = get_site_url() . '/dashboard/';
}

// Determine the secure cookie flag
$secure_cookie = null;
if ( ! force_ssl_admin() ) {
$user = is_email( $creds['user_login'] )
? get_user_by( 'email', $creds['user_login'] )
: get_user_by( 'login', sanitize_user( $creds['user_login'] ) );

if ( $user && get_user_option( 'use_ssl', $user->ID ) ) {
$secure_cookie = true;
force_ssl_admin( false );
}
}
if ( force_ssl_admin() ) {
$secure_cookie = true;
}
if ( is_null( $secure_cookie ) && force_ssl_login() ) {
$secure_cookie = false;
}

// Attempt to sign the user on. wp_signon() requires two arguments:
// 1. The credentials array and 2. The secure cookie flag.
$user = wp_signon( $creds, $secure_cookie );

// Ensure the redirect URL uses HTTPS if necessary
if ( $secure_cookie && strstr( $redirect_to, 'wp-admin' ) ) {
$redirect_to = str_replace( 'http:', 'https:', $redirect_to );
}

// Check if login was successful
if ( ! is_wp_error( $user ) ) {
wp_safe_redirect( $redirect_to );
exit;
} else {
// Handle login errors accordingly.
if ( empty( $creds['user_login'] ) || empty( $creds['user_password'] ) ) {
$errors['invalid_user_credentials'] = __( 'Please enter your username and password to login.', 'kvcodes' );
} else {
$errors['invalid_user'] = __( 'ERROR: Invalid user or password.', 'kvcodes' );
}
// You can then display or log the errors as needed.
}
}
?>

is the login script after that it shows the error

February 19, 2025 at 3:51 pm #16725744

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for sharing the login script. When using your login script, make sure to include the second parameter, as it is mandatory.

Please refer to the official WordPress documentation:

https://developer.wordpress.org/reference/hooks/wp_login/

For example, if you are calling further:

do_action( 'wp_login', $user->user_login );

You should modify it to:

do_action( 'wp_login', $user->user_login, $user );
February 19, 2025 at 4:26 pm #16725875

janineI

downgrading to version 4.0.4 solved the issue but im still confused what you guys changed

February 19, 2025 at 4:28 pm #16725910

janineI

without cms the error isnt there

February 19, 2025 at 4:43 pm #16726042

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Many changes and updates have been made since that version, so you are using an outdated one.

Please verify that your script adheres to WordPress standards. I believe that correcting the script should resolve the error.

I have created a staging site. Could you please replicate the issue there? I have included the link to the staging site in my next private reply.

February 19, 2025 at 6:48 pm #16726551

janineI

if ( isset( $_POST['login_Sbumit'] ) ) {

// Prepare credentials array for wp_signon
$creds = array();

// Get and sanitize the user login (username or email)
if ( isset( $_POST['userEmail'] ) ) {
$creds['user_login'] = stripslashes( trim( $_POST['userEmail'] ) );
} else {
$creds['user_login'] = '';
}

// Get and sanitize the password
if ( isset( $_POST['userPass'] ) ) {
$creds['user_password'] = stripslashes( trim( $_POST['userPass'] ) );
} else {
$creds['user_password'] = '';
}

// Check if 'rememberMe' is set and sanitize it
$creds['remember'] = isset( $_POST['rememberMe'] ) ? sanitize_text_field( $_POST['rememberMe'] ) : '';

// Determine where to redirect the user after login
$redirect_to = esc_url_raw( $_POST['redirect_to'] );
if ( empty( $redirect_to ) ) {
$redirect_to = get_site_url() . '/dashboard/';
}

// Determine the secure cookie flag
$secure_cookie = null;
if ( ! force_ssl_admin() ) {
$user = is_email( $creds['user_login'] )
? get_user_by( 'email', $creds['user_login'] )
: get_user_by( 'login', sanitize_user( $creds['user_login'] ) );

if ( $user && get_user_option( 'use_ssl', $user->ID ) ) {
$secure_cookie = true;
force_ssl_admin( false );
}
}
if ( force_ssl_admin() ) {
$secure_cookie = true;
}
if ( is_null( $secure_cookie ) && force_ssl_login() ) {
$secure_cookie = false;
}

// Attempt to sign the user on. wp_signon() requires two arguments:
// 1. The credentials array and 2. The secure cookie flag.
$user = wp_signon( $creds, $secure_cookie );

// Ensure the redirect URL uses HTTPS if necessary
if ( $secure_cookie && strstr( $redirect_to, 'wp-admin' ) ) {
$redirect_to = str_replace( 'http:', 'https:', $redirect_to );
}

// Check if login was successful
if ( ! is_wp_error( $user ) ) {
// Trigger the wp_login hook zodat bijvoorbeeld WPML functioneel blijft
do_action( 'wp_login', $user->user_login, $user );

wp_safe_redirect( $redirect_to );
exit;
} else {
// Handle login errors accordingly.
if ( empty( $creds['user_login'] ) || empty( $creds['user_password'] ) ) {
$errors['invalid_user_credentials'] = __( 'Please enter your username and password to login.', 'kvcodes' );
} else {
$errors['invalid_user'] = __( 'ERROR: Invalid user or password.', 'kvcodes' );
}
// Je kunt de errors vervolgens weergeven of loggen zoals nodig.
}
}

didnt work aswel still the same error