Adding Fields in WP-Members™

To add a new field, check the box marked Add Field and complete the details for the new field.

Parameters for all fields:

  • Field Label – this is what displays on the form
  • Option Name – name this will be stored as in the user_meta table (spaces not allowed)
  • Field Type – currently support text, textarea, and checkbox
  • Display – check this box if the field is to be used in registration form
  • Required – check this box if the field is a required field

Parameters for checkboxes:

  • Value – this is the value of the field if the box is checked
  • Checked by default – this will cause the checkbox to display as checked

Parameters for dropdown list:

Dropdown support was added in 2.6.3 and in 2.7 this was added to the Field Management panel.  If you add a dropdown list field, you must specify the values for the list items in the dropdown in the box provided.  This list should be provided in the following format:

The Displayed Text|the_stored_value,

  • “The Displayed Text” is the text that will display in the dropdown list to the user.
  • The pipe charatcer ( | ) is used to separate the displayed menu item from the stored value.
  • “the_stored_value” is the value that will be stored in the database if the user selects this item.
  • A comma must separate this list item from the next item in the list (no comma is needed after the last item).

These parameters account for a couple of extra features.  For example, if you want the list to start with something such as <–SELECT ONE–> but that this is not a selectable value itself, put the displayed menu item, followed by the pipe separator, and then a comma like this:

<–SELECT ONE–>|,

Alternatively, if you want a blank line as a separator between a group of menu items, simply use the pipe separator followed by a comma.

NOTE: if you add a password field, you MUST set this as both a displayed and a required field.

Once you have entered parameters for the new field and checked the Add Field box, click Update Fields to update the field list with the new field.  If your new field is not displayed in the list, it did not update.

Comments

  1. says

    Hey Chad, is there a way to edit a field once it’s been added? I need to change some text in the field label. For now I suppose I’ll jump into the database and edit there. Thanks!

  2. says

    Oh I guess I can’t really edit the database table .. whenever I make a change to the ‘wpmembers_fields’ in options table, I break the registration form.

    Okay so my next question … if I remove that custom field and create a new one with the same option name, will the new one pick up where the old one left off, so to speak? This field is a checkbox for opt-ins to our email marketing … I need to sort users later by checked and unchecked.

    I think this will work because the value of option name is getting stored in wpmembers_fields … so yeah, that’s what I’ll do. Thanks!

  3. says

    hey Chad,

    I am using your plugin but the fields are showing up twice. Would love your advice on how to resolve that. I had installed and uninstalled once before getting this to show up and work with captcha. Would love your help.

    Thanks!

  4. says

    Hi Chad,
    I just added a bunch of options and noticed that quotes are shown escaped in the field label and dropdown options. I’ll be digging into your code to address that, but if you could point me in the right direction I’d appreciate it.
    Thanks,
    Robert

    • says

      I’ll get it addressed. don’t know off the top of my head where updates will need to be, but I’m preparing a cleanup update 2.7.3 anyway, so this will fit into that process.

  5. says

    Hi Chad,
    I was able to resolve this issue by adding stripslashes to the us_option value on line 558 of wp-members-admin.php and adding a line to stripslashes from the $str value in the option section (lines 569-576). This is because the wordpress “update_option” function you are using already escapes the values, so this ensures it doesn’t happen twice.

    On a related note, I wanted to add income ranges as option values using commas a thousands separators (like $25,000) but your code separates the option values on commas so the results were off. I changed your explode function to use ||| as the array value delimiter instead of comma in order to allow commas in the option names and values.
    Regards,
    Robert

  6. says

    Robert,

    I could use some help in wordpress tweaks – such as integrating the Facebook/Twitter API to dump in the database. I am far less technical and work on the front end. You seem knowledgeble on the coding side. Are you available for freelance work in future?

    :)

    • says

      That all depends on what your objective is. There are a few possibilities.

      You can use get_user_meta to display the user meta fields. But most likely you’ll need to do this at the template level. To use this, you need a basic understanding of php and WP functions.

      WP-Members does have a “field” shortcode, but I’m not sure that’s what you are looking for (but just in case, I’ll explain it anyway). The field shortcode can be used to display any of the user’s registration fields in a page. (Note: this is the data for the user who is logged in.) The use of the shortcode is [wp-members field="option_name"] where option_name is the corresponding Option Name from the list of WP-Members fields.

  7. Jane says

    Can you let me know if there is a way to edit fields once they are added to the “manage fields” page?

    This would be a very helpful feature.

    • says

      There is not at this time. The reason is that, except in the case of a dropdown, it is actually easier to just recreate a field rather than edit an existing one.

  8. says

    Hi Chad
    Is it possible to add an automatic reguistration date field? I know how to add an extra field but I would like it to have a defaulkt vaklue of the current date.
    CHeers Soosie

    • says

      If what you are asking is to get the timestamp and date of a user’s registration, that’s already there. It is stored in the wp_users table.

  9. Xendo says

    Hi,
    thanks for your plugin.
    Is it possible to add a field to let the user choose between different roles I set up?
    I think I should use the dropdown select, but I wonder whether there’s a way to get the values from the existing one and updating that specific field in the database.
    Thanks again

    • says

      You could add that as a field, but depending on how you manage roles, you may need to include an intermediary step to sync up the two processes. If that is the case, you could probably do that using the wpmem_post_register_data hook. At that point, the user is registered as far as WP-Members and WordPress are concerned and the data is loaded into the database (wp_users and wp_usermeta tables). Using that hook, you could look at the usermeta that you are using for the user to set their role and then add whatever value the outside process needs.

  10. says

    Hi Chad! I’m wonder if there’s any possibility to set up 2 “checkbox” fields that you only can select one, for example to fields with no possibility to be both selected at the same time, for example to choose Male or Female. I was thinking in do it with dropdown menu but I can’t because the name are too long and I need to add a link to each field to read some Terms and Conditions on each… so needs to be two checkbox fields. Do you know what I mean? Thanks!!

    • says

      Actually, what you need are radio buttons. Unfortunately, there is not support for that in the plugin at this point. It’s something I’ve thought about, but haven’t had the time to build in at this point. There are a couple possibilities with the current plugin, however that would allow you to so some customization for something like that. How knowledgeable are you with php?

  11. Steve says

    Hi Chad, thanks for producing this plug-in. I need to make a few simple changes and I can send you the code once done if you wish. I simply need to add a “multi-select” field. If you can point me in the right direction, I’d appreciate it.

    Thanks

    • says

      Making changes in order to support another field type wouldn’t be a simple change. However, there is a very simple approach to this with a new filter hook that I haven’t really documented yet. If you are confident enough with php to be able to update the plugin in that way, then you’ll certainly be able to use the filter – and that will be not just simpler, but also compatible with upgrades.

      The plugin builds the form as a string of html. Before that is sent to the browser, it applies the filter wpmem_register_form. My suggestion would be to create the field you want as a regular input field, then use the browser to take a look at the generated source. Build a filter to use str_replace to put your multi-select html in the place of the regular input field (of obviously the same name).

      Let’s say you had a field for choosing what type of autos the user has owned and the option name of that field is “cars”. You had set it up as a regular input text type in the plugin field manager. You’ll apply this filter (like any other WP filter hook, this would go in your functions.php file):

      add_filter( 'wpmem_register_form', 'switch_to_multi' );
      
      function switch_to_multi( $form )
      {
      	// what is the original string we are looking for?
      	$old = '<input id="cars" class="textbox" type="text" value="" name="cars">';
      	
      	// what do you want to replace it with?
      	$new = '<select multiple="multiple" name="cars">
      		  <option value="volvo">Volvo</option>
      		  <option value="saab">Saab</option>
      		  <option value="mercedes">Mercedes</option>
      		  <option value="audi">Audi</option>
      		</select>';
      		
      	// replace the old string with the new
      	$form = str_replace( $old, $new, $form );
      	
      	return $form;
      }

      Now this is just random example. My html syntax might be off, but the php should be ok. I’m really just trying to give a conceptual example.

  12. Deeps says

    Hello Chad,
    wp-members is nice Plugin.
    I am using this plugin in my project , I can add many other Field using different Field Type like text,textarea,dropdown etc.
    now I want to add Upload resume filed in my Registration form so that, I need Field Type is “file”, how can i add in my Registration form.
    thanks in advances.

  13. Steve says

    Thanks for your reply Chad. I pretty much finished adding the multi-select field option by reverse engineering your code. I’m interested in adding a file upload field to be used as a member picture. I’m wondering how much you’d charge me to do this? I’m assuming you have access to my email address… thanks

    • Ron says

      I would be also interested in allowing members to upload their picture or Avatar. If this plugin caters to members, this would a standard function.

      Great plugin :)

      Ron

      • says

        At this point, there is not an upload option within the plugin. There are action and filter hooks available in the registration form and registration process that would allow this to be customized, and also WordPress has gravatar support built-in, so if the user has a gravatar, WP can load that via the user’s email associated with the gravatar.

        • Ron says

          You would have to customize the code to get WP-Members to add an Avatar via the WP email script. This is out of reach for the non-coder. You would think a members or membership script would allow the adding of an Avatar without having to create a hook or play with the WP CODEC. This plugin still rocks however missing this function is no fun. :(

          Regards,

          Ron

          • says

            No – I think you misunderstand. WordPress already loads user avatars from gravatar (globally recognized avatar) which are tied to the user’s registered email address. This does not require any coding what-so-ever. Now, if you have some limited coding skills you certainly can do more beyond that by using the get_avatar function which is certainly not out of reach of the non-coder.

            There is a good (and simple) example of how this works on my new premium support site. This particular post is free and shows you how to use get_avatar to add a gravatar to the sidebar widget using the wpmem_sidebar_status filter hook.

          • Ron says

            Hi Chad,

            Thank you for these great responses in all of these request – quite helpful.

            When you do not want individuals to go into the WP backend, nor use the WP registration routine – you are using ThemeYourLogin – the WordPress profile is no longer available – that is the purpose of using WP-Members is to help brand your own login, lost pass, change profile settings. Why not package this script with the ability to change your avatar? This seems like a natural thing to have set for future development.

            Ron

          • says

            I will probably be putting something together in the future that includes upload ability because I am getting requests for that.

            In the meantime, you might want to learn about gravatars which is what WP uses. There is no need to access your profile or anything on the backend to change your avatar if it is a gravatar. The avatar that is shown is connected to your email address, which if you want to change that, you can do that on the front end via WP-Members.

  14. says

    Hi,

    I seem to be having issues using WP-members i have adjusted the width in the wp-members.css but the text does not seem to be aligned with the names

    eg username [ textarea] comes up with *required field rather than the [ textarea].
    it skips a line and the username textbox jumps to the firstname text box.

    How can i resolve this?

    Thanks
    Aaron

  15. says

    Morning

    I use your plugg in as a registration form. Great!
    I just would like to be some parts of the registration visible to other members.
    When they register they most mention if the have a f-dog, a cat etc.. The other members must be able to see who has a dog or a cat.. help….
    I now use “member list” to show the members but it seems not to be working together…

  16. JVP says

    This is a great plugin! I’m using it for registering users on my site, but i want to know if is there any way to get the information of registered user, i ask for that because i’m using an external database used for a license program server, and i need to show to the user some information about the state of their software obtained from the external database.

    On the registration, i’ve added the product key that a user have to fill with their own key. When a user access to their member area, i want to call to the external database and get all the information about the user product status: activated/deactivated, last date used, remaining days of the product key, …

    Thanks in advance!

    • says

      The answer would depend on how you want to get the information of a registered user. There are several WordPress functions to do this (start with get_user_meta) The WordPress Codex is a treasure trove of information on this.

      Alternatively, if you are doing this external to WordPress, such as with a MySQL script, or direct access to the database, it is helpful to understand the relationship of wp_users and wp_usermeta (also found in the Codex). All of the additional fields in WP-Members that are not WP native fields would be found in the wp_usermeta table. Username and email will be found in the wp_users table (as will the user ID primary key to find the meta field value).

  17. Tania says

    Hi there- great plug-in. Really nice work. I’m using it as a way of gettin people to register in order to view video content on my site and it works a treat.

    The thing is now, I have a group of e-newsletters (one for general news, one for sports, one for business news), and I would like to add a field to the registration form which allows users to select more than one of those (they may want to receive them all). Is there a way to do this?

    Thanks again

    • says

      I would suggest adding a checkbox for each (which can be added in the plugin’s fields tab) as you can select checkboxes individually (as in the case of selecting one, some, or all).

      • says

        I have a custom field, a dropdown to be specific containing the options yes and no for the users to select if they want to subscribe to our newsletter. How can I make it work that if they opt to subscribe they will be added to the list in my mailchimp. Currently I have to separate lists for subscribers who wants our newsletter and the other one who is for members only.

        • says

          I would suggest playing around with the action hooks wpmem_post_register_data and wpmem_post_update_data. These come just after a user is registered and just after a user updates their registration data. You could write a function to subscribe/unsubscribe via the MailChimp API hooking in at those points.

  18. says

    Hi..I just added your members plug-in…firstly fantastic!
    Im new to wordpress…have just scrapped my iweb site that was completely customized but required my friend to design and make it all…as it got so complex I was asking to much of him so opted to redesign and create a wordpress site and manage our self myself…from the deep end..so far so good though.
    But to this members registration form. It doesn’t properly fit in our wordpress templates given space, please take a look for yourself. Ive tried changing to a portfolio page but that doesn’t work at all and also tried just removing the sid bar as it is now but as you can see that doesnt work either. Any advise you can give, its all so close to perfect, just needs some tweak to make it a little more narrow, please help!

  19. says

    Hi Chad,
    Thanks for the plugin. Quick question on a custom field. I’d like to display it on the WP-Members Users overview screen (Users > WP-Members Users). On the WP Members settings, I have that field set to “display”, but it doesn’t show up on the overview screen. I’ve set all the other fields to NOT display (except username, name, and email) and, true to expectation, they do not display. Not sure why that doesn’t work on a custom field.
    Thanks!
    Carrie

    • says

      Hmmmm… Not sure why that would be. Is it a field that you added or is it one that was part of the plugin’s default install?

        • says

          That sounds like something I’m going to need to troubleshoot. Unfortunately, I’m not currently in a good location to do that, so it might take me a couple of days to be able review.

          • says

            Actually, it appears that I misread your original question. I thought you were speaking about the User Profile page, but you are actually referring to the User Table.

            The User Table fields are not changeable at this time, so the fields that show are the fields that show.

            The current version 2.8 project revolves around changes to the admin panels, and it is in the project to make changes to how this table is editable. In the first iteration it will probably be editable via filtering an array of the available fields, with the possibility of adding something via the admin panel later on down the road.

  20. Mikey says

    Hi Chad. I don’t know if this was answered above, but I’m having trouble with the checkbox feature in the field. I want to make it so people can check off a few features. Is there a more organized way than having a bunch of check boxes separately placed? Thanks

    -Mikey

    • says

      I think I understand what you are looking for, but no, there’s not really a way to group them together. However, if you have some php skills, you could filter the generated html for the form to manipulate things the way you want using the wpmem_register_form filter hook. See the list of hooks here for more information on this hook.

  21. says

    Chad, I use your wp-members plugin on one of my sites. Just installed it, nice plugin. But I have first and last name as required fields, and the plugin is allowing the users to submit their registrations with no first or last name, no TOS checkbox or Country. These are all required but users are successfully bypassing this important requirement. Will you help me fix this :) ?

  22. says

    Chad, having issues with passwords. Originally setup where the approval email would give password, this relies on correct email and being able to type auto password. There were (are) too many issues with members. I am trying to get the password field setup where the new member adds their password (this part works), and the auto reply email has their username and password (this part doesnt work, the password is blank). Field label, option name and field type are all “password”, display, required, checked are all checked.