Skip to:
Content
Pages
Categories
Search
Top
Bottom

Generate username (+ blog url) from fullname

  • Avatar of Peterverkooijen
    peterverkooijen
    Participant

    @peterverkooijen

    I need to write a plugin or modify registration to generate the username from the fullname.

    I use the email-login plugin, so I’d like to remove the username from the registration form.

    The fullname field would require a real full name, so more than one part, first and last name – including middle names and whatever, the code would assume the first part is the first name.

    Then there would have to be a function to make everything lowercase and remove spaces and put that into the username field – with all the regular checks and error messages.

    The blog address would take that same username, based on the full name, as default option.

    Would this be possible? How much of this is already in WordPress or Buddypress? Are there plugins that do parts of this? Is anyone working on something similar? Where should I start?

    I’m not really a coder. I understand I’ll need to learn from scratch or hire someone. Just trying to get a better picture of where to start, what’s already there, etc.

    I had started a similar thread here, but it went off the rails a bit. This thread is an attempt to refocus the question.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    This is a nice and succinct accounting of what you are trying to achieve. Parsing a registrants first and last names from the BP “Full Name” field and then using that as the username would be a nice option.

    But I’m not too sure whether you can remove–or hide as would actually be the case–WPMU’s username field from the registration form. WPMU is the underlying foundation of the system. It controls everything. With enough coding, I’m sure it would be possible–but not that sure on the practicality of doing it.

    As I had suggested before, I would head on over to the WPMU forums and post a similar thread since this deals with hijacking, altering, and superseding WPMU’s registration protocols. That way, you will hopefully get some feedback on both fronts and find a possible, acceptable solution.

    Avatar of Peterverkooijen
    peterverkooijen
    Participant

    @peterverkooijen

    But I’m not too sure whether you can remove–or hide as would actually be the case–WPMU’s username field from the registration form. WPMU is the underlying foundation of the system. It controls everything. With enough coding, I’m sure it would be possible–but not that sure on the practicality of doing it.

    Hiding a field on a form is not that difficult. As long as the required data gets added to the database by some other means it doesn’t change the underlying foundation at all.

    It is not a WPMU issue. I don’t want to change the underlying foundation. I want to use Buddypress’ fullname field to generate that username.

    The WPMU forum will just send me back here and rightly so.

    One way off the top of my head would be to inject a JavaScript into the registration page – you’d use the BP name function to get what you want. There is already Wp code for “sanitizing” blog post names, and perhaps other areas too. Then it’s a matter of using the JavaScript to set the HTML field’s value, and CSS to hide it.

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    Hiding a field on a form is not that difficult. As long as the required data gets added to the database by some other means it doesn’t change the underlying foundation at all.

    As I said, I’m sure that with enough coding you code get this to work. But it might require core hacking. If so, that would be a change to the underlying foundation. I’m not sure without trying it so your best bet is to talk with the WPMU gurus on their forum.

    It is not a WPMU issue.

    The WPMU forum will just send me back here and rightly so.

    Whereas they may indeed send you back here, it is a WPMU issue. Just because you think it is a BuddyPress issue does not make it so. I’ve said that several times, DJPaul has said that, jjj has said that as well.

    WPMU’s functions take care of the underlying registration process. BuddyPress just hooks into that process, adding a few of its own fields and checks along the way. WPMU does not allow you to position the username field in a different sequence–not without behind the scenes changes. Of course it is easy enough to hide it via CSS, but whether or not you can then write data to it, bypassing WPMU’s field validation protocols is a different story. I have not tried that. I am not sure. But, it is a question that must be asked of WPMU, not BuddyPress.

    You said above that:

    I’m not really a coder. I understand I’ll need to learn from scratch or hire someone.

    Well, if you aren’t looking at how the underlying registration functions are coded, then how can you say with such certainty that this is not a WPMU issue?

    I have not spent all the time that I have responding to your various questions in your various threads to get rid of you. If I didn’t want to help, I would simply have ignored your posts. I’m offering you support and pointing you in the best direction for the given issue. You can choose to ignore my advice. That is your prerogative.

    Perhaps you’ve already spent time on the WPMU forums and did not get the response you have wanted. We’ve been as helpful as we can here.

    Without contracting with a coder or coding yourself, you’re out of luck.

    Avatar of Peterverkooijen
    peterverkooijen
    Participant

    @peterverkooijen

    One way off the top of my head would be to inject a JavaScript into the registration page – you’d use the BP name function to get what you want. There is already Wp code for “sanitizing” blog post names, and perhaps other areas too. Then it’s a matter of using the JavaScript to set the HTML field’s value, and CSS to hide it.

    Thanks DJPaul! That sounds doable. Would it be possible to put that in a plugin or would it have to be inserted in core files?

    Well, if you aren’t looking at how the underlying registration functions are coded, then how can you say with such certainty that this is not a WPMU issue?

    What I need wouldn’t touch the underlying registration functions. All I need is another way to insert that username into the database on registration. Hiding a field on a form is basically an html/css issue, stuff that I know enough about.

    Again, if the username would be generated from Buddypress’ required fullname field, it by definition is not a WPMU issue.

    Also getting a more consistent connection in how Buddypress and WPMU handle first name + last name is not a WPMU issue; it’s about how Buddypress (x-profile) hooks into and synchronizes with WPMU.

    WPMU does not allow you to position the username field in a different sequence–not without behind the scenes changes.

    I have already done that once. It’s no problem. It’s annoying WPMU mixes presentation and functionality in the registration, but I’ll work with what I get.

    Without contracting with a coder or coding yourself, you’re out of luck.

    I am trying to code myself where I can and am certainly considering contracting a coder. I need to figure out what I need exactly first. Also with these posts I’m trying to point out some imho weaknesses in Buddypress that should get more attention and judging from the private comments I’ve received I’m not the only one struggling with these issues.

    Avatar of rickgoz2009
    rickgoz2009
    Participant

    @rickgoz2009

    Any progress on this plugin?

    Avatar of Peterverkooijen
    peterverkooijen
    Participant

    @peterverkooijen

    My latest attempts were here, for a plugin for a related problem that will hopefully also lead to a solution for username/blogurl.

    I have to decide first how I am going to put firstname + lastname into the database; split the fullname value out to wp_usermeta or turn fullname into firstname and add another xprofile field for lastname.

    Again, I’m not really a php programmer. I’m trying to puzzle it together from code examples and googled bits and pieces. I’ll need all the help I can get!

    I can’t figure out how the fullname moves from the registration form to the database; which pieces of code are involved and how to “intercept” it to “do stuff” with it. That’s where I’m stuck at the moment.

    “user profile meta” is put “in a session ready to store”. Is that an “array”? Anyway, that’s higher level php to me. No clue how to extract the fullname value from that.

    // put the user profile meta in a session ready to store.
    for ( $i = 0; $i < count($bp_xprofile_callback); $i++ ) {
    $bp_user_signup_meta['field_' . $bp_xprofile_callback[$i]['field_id']] .= $bp_xprofile_callback[$i]['value'];
    }

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

You must be logged in to reply to this topic.