Is it possible to read a result if wp_update_user or update_user_meta fails?

wordpress.stackexchange https://wordpress.stackexchange.com/questions/10456

  •  16-10-2019
  •  | 
  •  

Pergunta

I am using both wp_update_user() and update_user_meta() and I want to be able to check for an error, and if one occurs, output it to the user. Is this possible using something like $result = wp_update_user()? I don't want an integer though I want to read the text of the error.

Foi útil?

Solução

Not really. Deep down such functions are essentially writes to database. So either database write fails (which doesn't produce meaningful message to return) or data is somehow wrong and function just returns false to escape.

Your best bet is probably to control data user inputs, not result of WP trying to process that data.

PS worth mentioning that for debug WP_DEBUG and wpdb error echoing rock, but it's not exactly what you are asking for.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange
scroll top