The MU forums have moved to

Helping to understand filters (2 posts)

  1. plaverty
    Posted 12 years ago #

    I'm trying to override some core functionality here. When a blog admin wants to add someone to their blog, they simiply add a new user with their username and email address. If that person is not already in the system, WPMU creates a new account and sends an email to the user for confirmation. I'm ok so far.

    One of the checks that WPMU makes against the username is through wpmu_validate_user_signup. This function will first call sanitize_user. Sanitize_user will allow a @ and . if strict is set to true. Then control goes back to wpmu_validate_user_signup, which then checks if the username is alphanumeric. If it's not, it adds the error that "Only lowercase letters and numbers are allowed". Then continues on.

    So my question is, if I add a filter on to sanitize_user, is that going to help? It seems that after sanitize_user is run, the code continues on with more checks. How do I add a filter to santize user to tell it to not kill the username in wpmu_validate_user_signup after it finishes with sanitize_user?

    I'm really new to writing plugins, but in my little procedural mind, this is how I see it:

    Step 1: Submit Username
    Step 2: wpmu_validate_user_signup function is called
    Step 3: sanitize_user is called from function above
    Step 4: This is where the my plugin/filter would jump in
    Step 5: Control goes back to wpmu_validate_user_signup and it does more checks against the username
    Step 6: Returns error

    Where is my thinking wrong on this? How can I get it to not do step 5?

    If I just need to RTFM, I'm happy to do so, I'm search the Codex and all over google for the right way to handle this one. Just suggest a link, please.

    Thank you.

  2. DeannaS
    Posted 12 years ago #

    Check out what I did in this plugin:

    It's doing the same thing, except for overriding the restrictions on blog names instead of usernames.

    I think it'll help you along.

About this Topic

  • Started 12 years ago by plaverty
  • Latest reply from DeannaS