Membership User Names

We're configuring the latest Beta of Membership for (which is built out of awesome WPMU goodies) and I've run into a rather large bump in my smooth sailing.

I need to give every user that registers an automatic ID number as their user name instead of having users named smith, for example.

I found some sparkly code that sort of does that here:

Create a unique ID for new users

But I'm unsure of how to make this mesh with Membership. We're willing to do some custom coding, but before we do so, I want to be sure I'm not going to muck anything long range up.

Why we need the unique id is because the 9000 ish members have a number of common last names, like 67 Smiths, for example. When we originally configured Membership on the site we attempted to create unique user names for each member, but we found that one Smith could easily screw up another Smith without breaking a sweat.

We then made the decision to use a unique ID as the user name. That also allows us to use the communications tool to send that number out automatically to new members instead of us having to manually issue them via Salesforce.

If anyone has a more brilliant suggestion please chime in, but otherwise, my original question stands, how do I do this and should I do this?

Thanks -


  • phillcoxon

    Wow - 9000 users? That's awesome. :slight_smile:

    I'm not quite following how the problem occurred - do you mean when two "Sally Smiths" signed up and tried to use the same username? Or were you getting corruption somehow?

    As far as unique user ids, every time a user joins they are already allocated a unique user id in the wordpress database. So in theory it shouldn't be too difficult to have users log in with their user id instead of their username.

    The downsides could be:

    1) Needing to confirm that WordPress never changes user ids. I can't think why it would but I'd double check that in a few places.

    2) Weakened security - instead of two alphanumeric variables associated with a login it is reduced to a number and password. That will make it easier for attackers to use scripts to try and break accounts - generally not too hard given the terrible passwords general non techy users often use ("qwerty", "password" etc.)

    An alternative would be to have users log in with their email address as that would always be unique to each user?

    Not sure of the compatibility with Membership but it should be fine.

    Let me know if that's helpful.

  • suecline


    I should have been more clear, we have to associate a User Id regardless of whether it's set as the user name or in another field. Basically, when someone joins through the membership module, I need WordPress (hopefully via the membership module) to issue that unique id.

    We discussed email logins and there are some strong arguments in favor of that to be sure.

    One way or another, though, each user and membership (even free ones) has a unique ID that ties back to their CRM/donor management system, and since there is no current linkage to Salesforce, issuing the User Id via WP is one way I can hinge the data export back into the contact record.

    Hope that makes more sense!

    Thanks -


  • phillcoxon

    Oh I see! I hadn't understood the relationship with the CRM system.

    So how does the unique id currently tie in with the CRM? Is it done manually - i.e.: someone copies the details from Membership and pastes them into the CRM?

    Or is it an automated process?

    It's easy enough to display the user's unique user id in the WordPress admin panel using plugins:


    A better way might be to have a custom hook on wordpress registration that sends all the new user info including unique ID, email address etc to your CRM software if it has an API that can receive data.

    Do either of these ideas sound like they could be a solution?

  • suecline


    You're speedy today!

    Right now, connecting to the CRM is a manual task I'd love to automate.

    Of the two options, your second choice, creating a custom hook that fires off to the API via REST might well be my better choice here, based on a quick reading of the situation.

    As usual, the challenge will be finding someone willing to do that work at NP compensation levels LOL


  • phillcoxon

    I think that the API option wouldn't be too difficult.

    WordPress will allow a custom hook after the registration process that could be used to send the user data via the API.

    The trick though is that you really want to send additional data about what Membership level they are on, right? So there ideally needs to be some way to activate the API after the members finish joining a membership level.

    Although I haven't used the feature myself this is what the Membership Ping feature is all about.

    So a Ping script could be written and stored alongside membership that receives all the user data, user id, email etc and then transmits that to salesforce via the API.

    It could have built in error logging so that if the API transmit fails then someone receives an email with the user's details to add it manually, or perhaps with a link to the ping script to try sending it again.

    Overall... it's probably only 4-6 hours work.

  • phillcoxon

    To get this work done you could list a job over at or I've heard good things about

    By the way - I should state that the 4-6 hours work is only a rough estimate off the top of my head. It depends entirely on the complexity of the script. But for bare bones 4-6 hours should do the trick.

    I also just double-checked the membership ping fields and yet it can send userid, email, membership level, name along with a bunch of other stuff.

    Sounds like it could be the solution you're looking for!

    Best of all it wouldn't involve custom changes to Membership itself that would potentially be overwritten by a future Membership upgrade.

  • suecline


    Do you happen to know if there are example ping scripts hanging out here for us to work from? I have read all the documentation and it's a bit...thin on the ping sequencing.

    Ideally yes, what would happen is this:

    Guest visits site
    Decides to join
    Completes a custom join form (I need a couple custom fields) and selects membership type
    Ping fires up and sends to API
    Adds new record or modifies existing record at Salesforce

    If you're interested in doing the work email me a quick proposal - I would really like this functional so I can move this 18 month project into the 'done' box :wink:



  • phillcoxon

    I'm sorry - I can't help with this personally - I'm already waaaaaay overloaded at the moment and my php skills are a bit rusty.

    It's pretty simple stuff though. The only thing that would need to be checked is the custom form fields, but the ping script could always pull those directly from the WP database if Membership can't pass them over. The simplest script would only send new client data to SalesForce. Updating clients if they change details (name, email address, membership level etc) is definitely doable (depending on the salesforce api of course) but will increase the complexity.

    Overall though, compared to the time and staff costs of doing this all manually now I think getting this coded will be a great return on investment. Please feel free to pay me a "finders fee" heh. :slight_smile:

    Let's wait and see if some of the more experienced staff agree but I think we're on the right track here.

  • Will Ashworth

    Is there a uniquely matching "something" between both WordPress and Salesforce that we'll know will match up the two systems before we add the other field to existing accounts on Salesforce?

    If yes, this is pretty simple, and we're somewhere in the ballpark that Phil mentioned for hours, barring any unforeseen circumstances. If not, then it needs to be scoped out a little more.

    I know there are PHP wrappers for Salesforce to make working with the API a little easier, and the only piece remaining would be figuring out how to "hook" into the membership module in WordPress. I haven't looked over the documentation just yet to see if it supports the addition of new logic to the system, but it's probably something you can do via functions.php to extend how the membership module "behaves".

    On the surface, it seems reasonable to expect that the "ping" function of the Membership plugin should let you talk to just about any RESTful API out just put together whatever header is needed for the 3rd party system.

  • suecline

    I wanted to update anyone else following this issue that, while it wasn't the 6 hour project we'd hoped for, we did, finally, successfully build this bridge and our membership module is now connected to and updating Salesforce in real time.

    I want to thank everyone who suggested this option, and extra big thanks to fellow WPMU member mindblazetech for stepping up and making the whole system work!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.