• I am wondering if it is possible to add two checkbox fields to the install.

    1. email
    2. bulk email

    These need to both have a default value of true

    Is it just a matter of adding two extra fields to the install file???

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • There is a description of customizing the fields here:
    https://butlerblog.com/2010/09/27/adding-custom-fields-in-wp-members/

    However, it’s not set up to handle checkboxes in the registration. I’ve been thinking about adding that feature (and the new version currently in beta testing does have a Terms of Service checkbox option) so I’ll add that to the list for the next development cycle.

    In the meantime, there is a possibility for adding a checkbox as the core generates fields with its own wpmem_create_formfield function and that does have a checkbox as a possibility. But it’s not as simple as just modifying the install since you’ll need to account for passing the value to the function when the fields are generated. I’ll try to outline the process here.

    Begin by familiarizing yourself with the process outlined at the link above. Then you can modify the install adding a field array for the checkbox field. Add the value for the checkbox at the end.

    array ( 17, 'bulk email', 'bulk_email', 'checkbox', 'y', 'y', 'n', 'true')

    The array is as follows:
    order (not used), label, optionname, type, display, required, native
    and we are adding an extra value at the end for the checkbox value

    IMPORTANT: You’ll also need to set whether this field is required or not. Changing the admin to accommodate changing this through the admin panel would require additional code changes – it’s easier to just “set it and forget it” in this case. Also, since “email” is already used as a required (and unchangeable) field, I don’t think you can use just ’email’ as the field name for your one box. You should be able to use it for the field label (the first text in the array), but not the name.

    Also, if you are doing this on the 2.3.2 or earlier production version, you’ll need to make sure you’ve followed the instructions in the post I linked to regarding deleting the existing settings you have prior to reinstall. If you are using the 2.4 beta release 4 (available here | info about here) there is a toggle in the install file to force an install (line 32 change $chk_force to true) which makes this easier.

    You’ll need to make a change to wp-members-dialogs.php to accommodate the checkbox fields. In 2.3.2 this is at line 179. In the 2.4.0 beta release 4 it is at 216.

    Change:
    wpmem_create_formfield($wpmem_fields[$row][2],$wpmem_fields[$row][3],$val,'');

    To:
    wpmem_create_formfield($wpmem_fields[$row][2],$wpmem_fields[$row][3],$val,$valtochk);

    And just before it, add:

    if ($wpmem_fields[$row][3] == 'checkbox') {
    $valtochk = $val;
    $val = $wpmem_fields[$row][7];
    }

    The important caveat here is that by making changes to the code, you are rendering your installation un-upgradable without reintroducing the changes. Normally, I not only recommend against that, I don’t generally post exact changes like this for that reason. But in the case, I probably will add checkboxes in the next production cycle and they will probably be similar to the description above (although full testing is needed).

    Hope that helps.

    Thread Starter rogerr

    (@rogerr)

    Wow… Fantastic.. What service… Donation is making it’s way to you!!!

    Yippee… WP-Members now works seamlessly with Email-Users 3.1.8 with WP-Members being the primary registration.

    OK, Changes are made and all good… I had to make a few minor mods as below.

    Using 2.4.0 beta release 4, I have added the following to the array in wp-members-install at line 60:

    array ( 17, __('Accept Emails', 'wp-members'),'email_users_accept_notifications', 'checkbox', 'y', 'y',' n' ),
    array ( 18, __('Accept Newsletters', 'wp-members'),         'email_users_accept_mass_emails', 'checkbox', 'y', 'y',' n' )

    Also changed wp-members-dialogs line 216 to:

    if ($wpmem_fields[$row][3] == 'checkbox') {
    								$valtochk = $wpmem_fields[$row][7];
    								$val = 'true';
    								}
    							wpmem_create_formfield($wpmem_fields[$row][2],$wpmem_fields[$row][3],$val,$valtochk);

    The only thing I still need is to have the checkbox checked by default??

    One quick thing… As some of us (ie. the rest of the world) don’t use zip codes but postcodes, could you maybe change the label “Zip” to “Postcodes/Zip” on line 50 of the install???

    Again Many Thanks

    Rog

    How do you get it to work seamlessly with Email Users? Let me know if my approach is off the mark…

    I created two new user roles: Yes_Email and No_email. “Yes_Email” is the default role.

    I want WP_Members to add a new user into the “Yes_Email” bin if the question “Receive Emails?” is checked. And if not, they will go into “No_Email.”

    I have tried to get this working and have not been successful yet.

    I am curious how you are using your checkbox to work with Email Users. Since Email Users determines its groups based on user roles, how are you using WP_Members to sort which users to send emails to?

    That might require some type of intermediary script to sync up.

    I haven’t really looked at the email plugins that are out there, but probably will since I’ve been getting lots of questions on them lately. Also, I am considering an email module specifically for WP-Members.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP-Members Additional Fields’ is closed to new replies.