Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to hook validate_username (or sanitize_user) in WP?
    text
    copied!<p>I am new to wordpress and I am just learning it. <strong>How to hook validate_username or sanitize_user functions?</strong></p> <p>I do not want to call them at all, I want to change them for my particular plugin.</p> <p>Here is the full story: My problem is that I do not know how to change existing WP functions correctly without modifying them (some hooks or something like this).</p> <p>I have the following problem:</p> <ul> <li>I have a plugin theme-my-login that shows registration form</li> <li>it has register_new_user (that handles registering a new user) -> it is not wp standard function, but is written in plugin</li> <li><p>this function calls WP standard validate_username:</p> <pre><code>function register_new_user( $user_login, $user_email,$term, $country ) { $errors = new WP_Error(); $sanitized_user_login = sanitize_user( $user_login ); $user_email = apply_filters( 'user_registration_email', $user_email ); // Check the username if ( $sanitized_user_login == '' ) { $errors-&gt;add( 'empty_username', __( '&lt;strong&gt; ط®ط·ط£ &lt;/strong&gt;...', 'theme-my-login' ) ); } elseif ( !**validate_username**( $user_login ) ) { //HERE WE CALL WP VALIDATE_ $errors-&gt;add( 'invalid_username', __( '&lt;strong&gt; ط®ط·ط£ &lt;/strong&gt;: </code></pre> <p>....</p></li> </ul> <p>So, the problem here is that *validate_username* doesn't allow usernames to be in arabic language. But this is what client wants. So, I believe I should overwrite or somehow modify existing WP validate_username or sanitize_user (both are in wp-includes/user.php).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload