latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Hook to help validate user name

Home Forums Community Forum Hook to help validate user name

This topic contains 3 replies, has 2 voices. Last updated by  Matt Denman 3 years, 9 months ago.

Topic Author Topic
Posted: Wednesday Apr 3rd, 2013 at 7:31 am #46455

I really like what I see in s2Member and want to upgrade to pro, but have one concern holding me back.

I need to be able to do an ajax call to an external system to validate the user name picked by a registering user. I’d like for that ajax call to happen on the blur event of the user name field.

I know that I can customize the registration template in pro and do it that way, but I’m concerned because that approach doesn’t unify the naming requirements of wordpress with the external system. What if the external system says the user name is valid but wordpress says it isn’t?

The scenario I worry about is the user types a user name, tabs off the field, see’s the green checkbox from my external system check and then gets an invalid user name error when they submit the registration. Is there a way to validate the user name with wordpress via ajax so that I can check both systems?

Is there a known pattern of integrating with an external system?

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Wednesday Apr 3rd, 2013 at 7:38 am #46456

To clarify, I have an external system that has its own security and user names. I am trying to sync the two, such that when a user registers with s2Member on the site, I can create a new user for them on the external system.

The external system has its own minor rules for valid user names. I have a web service I can call to check to see if a user name is valid, which is what I want to call via ajax from the web page during the blur event of the user name field.

I think the best option would be to have a way to check wordpress for the user name being valid at the same time I check the external system. I would only show the “good image” when both wordpress and the external system say the desired user name is valid.

Posted: Wednesday Apr 3rd, 2013 at 6:57 pm #46556
Bruce
Username: Bruce
Staff Member

Thank you for your inquiry.

I think the best option would be to have a way to check wordpress for the user name being valid at the same time I check the external system. I would only show the “good image” when both wordpress and the external system say the desired user name is valid.

Yes, I believe that’s the only way you could accomplish this. This function might help you:

http://codex.wordpress.org/Function_Reference/validate_username

As far as integrating this with s2Member goes, you could do it by grabbing ID of the Username field through something like Firebug, and add a JavaScript event that way, or you can use the information provided here to integrate it with Pro Forms with s2Member Pro:

Pre Sale FAQs » Is it possible to modify s2Member® Pro Form templates?

Posted: Wednesday Apr 3rd, 2013 at 7:38 pm #46559

I have been able to piece together a solution from a variety of posts and articles from the s2member.com site and I am now happy.

1. User names are validated against the external system AND wordpress during blur event.
2. The chosen user name is again validated on the server side against the external system and only then will it process the paypal stuff.

I am now just about done hooking up the create/delete notifications so that the external system can sync user access.

I will eventually want to sync passwords so that when the user changes the password on the wordpress site it updates the external system.

Viewing 3 replies - 1 through 3 (of 3 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.