• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Store
    • Cart
    • Checkout
  • Blog
    • Basics [Free]
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Contact
  • Sign In
  • Show Search
Hide Search
Home » Filters » Multiple Selection Checkboxes

Multiple Selection Checkboxes

Chad Butler · Oct 15, 2013 ·

As of WP-Members 3.1.0, multiple selection checkbox support is an included feature in the plugin. That makes custom implementation such as described here unnecessary for most applications. I am leaving this post here however as there may continue to be users who (1) need a high level of customization that may utilize some or all of this kind of approach, and (2) for users who may not update to 3.1+ who need this support.
Note that there is now a more flexible example of multiple selection checkboxes here. This example is easier to set up and allows for multiple checkbox groups.

Something that will probably become a full feature in the main plugin is multiple selection checkboxes. However, until that becomes a full feature, here is a code snippet that you can use to set this up in your existing installation.

This article is only available to WP-Members Support Subscribers. If you have an existing subscription, please login below. If you do not have a current support subscription, you can purchase a support subscription here.

Already a Member? Log In Here
   
Forgot password? Click here to reset

To gain full access to WP-Members premium content, a current support subscription is required. You can purchase an annual support subscription for as little as $59, which provides you with access to priority support, a customer support forum, access to code snippets, and more.

Why wait? Choose your subscription option here.

[
Why join?]

Filters explode, filters, strstr, str_replace, wpmem_admin_profile_field, wpmem_admin_profile_update, wpmem_email_notify, wpmem_register_data, wpmem_register_form

Welcome to RocketGeek Interactive › Forums › Multiple Selection Checkboxes

Tagged: explode, filters, multiple check boxes, strstr, str_replace, wpmem_admin_profile_field, wpmem_admin_profile_update, wpmem_email_notify, wpmem_register_data, wpmem_register_form

  • This topic has 22 replies, 8 voices, and was last updated 6 years, 1 month ago by Chad Butler.
Viewing 8 reply threads
  • Author
    Posts
    • October 15, 2013 at 3:10 pm #3165
      Chad Butler
      Keymaster

      Something that will probably become a full feature in the main plugin is multiple selection checkboxes. However, until that becomes a full feature, he
      [See the full post at: Multiple Selection Checkboxes]

    • December 6, 2013 at 2:36 am #3570
      attentionwebdesign
      Blocked

      I was happy to see this post as I was looking for the same thing.
      But:
      I have set this up on my site (not public yet) and the registration form looks fine (same as before when the checkboxes weren’t related) but it doesn’t work properly on the output side of things.
      The email sent to the admin lists the checked answers for EVERY checkbox field, instead of just once. So there is a list like:
      Field1: answer1, answer2, answer3
      Field2: answer1, answer2, answer3
      Field3: answer1, answer2, answer3
      etc. for each checkbox.
      And – NONE of these answers are displayed on the member list. Just a big blank space where they should be. I was expecting a comma separated list.

      Any more snippets to make this work in the email and on the member list? Thanks!

    • December 8, 2013 at 2:29 pm #3585
      Chad Butler
      Keymaster

      Hi Teresa,

      I’ve added to the post to address the email issue.

      I’ll look into the user list problem next.

    • January 18, 2014 at 8:49 pm #3890
      CodeWiseCreative
      Participant

      But… that just removes it from the registration email rather than actually fixing it so that it is readable in the registration email. hmmmmm

      • January 18, 2014 at 9:06 pm #3892
        Chad Butler
        Keymaster

        Actually, if done as indicated, it should put the values into one line and remove the other two (the example being three checkboxes)

    • February 11, 2014 at 8:00 am #4084
      zylion
      Participant

      This method when applied makes one established field inaccessible due to the same id -when you want to modify or delete one checkbox – the whole array is being deleted.

      • February 11, 2014 at 10:06 am #4085
        Chad Butler
        Keymaster

        You are referring to making changes in the field manager tab, correct?

    • February 26, 2014 at 8:44 am #4240
      pelles
      Participant

      I’m having trouble with this function. I’ve followed the instructions above but the form only displays the last option.

      The code in functions.php looks like this:

      $wpmem_multi_chkbox_name = ‘sponsor_details’;

      function build_checkbox_array()
      {
      /** SET THESE TO THE VALUES OF YOUR CHECKBOXES **/
      $options = array( ‘self’, ’employer’, ‘sponsor’, ‘other’ );
      return $options;
      }

      • February 26, 2014 at 2:19 pm #4241
        Chad Butler
        Keymaster

        Did you create a checkbox for each of these values? You should have four checkboxes with option name “sponsor_details”, each with one of your possible values?

        • February 26, 2014 at 2:23 pm #4242
          pelles
          Participant

          Yes.

          Delete Self sponsor_details checkbox edit
          Delete Employer sponsor_details checkbox edit
          Delete Sponsor sponsor_details checkbox edit
          Delete Other sponsor_details checkbox edit

          But if I press Edit on any of them I see the information of the last checkbox.

          • February 26, 2014 at 5:14 pm #4243
            Chad Butler
            Keymaster

            On the admin side that is true – you won’t be able to edit these form elements in the form manager once you set them up (other than delete them and start over).

            So is that where the problem is? Are they showing up in the registration form correctly?

          • February 27, 2014 at 12:49 am #4250
            pelles
            Participant

            No. In the registration form only the last checkbox is visible.

            https://www.evernote.com/shard/s1/sh/27de4fb9-7725-4685-bc37-9e872b491a4e/e55543e4a2b93e2853443936ae9c6ebf

    • February 27, 2014 at 10:46 am #4258
      Chad Butler
      Keymaster

      Hmmm… So something is definitely missing here. Is the site in a location that I could take a look (front and backend)? If so, send me a note through the contact form with some login credentials and I’ll take a look at it and see if we can get it working. Also note which version of the plugin you are using.

      • April 20, 2014 at 1:29 pm #4690
        sabrinal
        Participant

        Hi Chad,
        I’m having the same problem as Pelles. I have created all the options in the admin and then edited the functions.php but only one the 2nd option is showing up in my form and when I click on the option one in the admin it shows all the info for option 2. Any suggestions?

        http://www.mercadyne.com/merchant-liquidity-fund-lp/principal-and-fund-portfolio/

        global $wpmem_multi_chkbox_name;
        $wpmem_multi_chkbox_name = ‘character’;
        function build_checkbox_array()
        {
        $options = array( ‘net_worth-1m’,’individual_200k’ );
        return $options;
        }

        Delete option 2 character checkbox edit
        Delete option 1 character checkbox edit

        • April 21, 2014 at 4:45 pm #4701
          Chad Butler
          Keymaster

          I think that using the new wpmem_register_form_rows filter in 2.9, I have a way to make this a little simpler. I just finished putting together a code snippet for it with the new filter hook. I will get that posted on the site for you tonight and will post here when it is up.

          The new process only requires you to create one checkbox as a placeholder and will insert as many mult-check options as you need. That makes the process cleaner and more fool-proof (hopefully). It also eliminates the need for the complications of adjusting the form.

          • April 22, 2014 at 5:37 pm #4734
            Chad Butler
            Keymaster

            I put together a new tutorial with a new code snippet taking advantage of the new 2.9 filter wpmem_register_form_rows which makes the process MUCH cleaner. You can check that out here:

            https://rocketgeek.com/filter-hooks/multiple-selection-checkboxes-2/

    • October 7, 2014 at 7:30 am #6039
      amca
      Participant

      Sorry, I’m a total noob.

      Where do you add all this code? Is it just in functions.php?
      Is there an (easy) plugin you can suggest to add and edit these code snippets.

      Thanks!

      • October 7, 2014 at 9:17 am #6040
        Chad Butler
        Keymaster

        No problem – that’s a pretty normal question. Yes, it goes in functions.php. It’s mentioned in the post, but it can be easily overlooked. 99% of the time, that’s going to be the case.

        You raise another good question about adding/editing code snippets. There’s not really a need for a plugin to do that – it’s already built into WordPress. You can edit your theme’s functions.php file in the theme editor (Go to Appearance > Editor, select the theme if it’s not already, then select Theme Functions / functions.php from the list on the right). It wouldn’t make sense to add a plugin to do this.

        One important thing to note is that it is generally better to edit functions.php locally and ftp transfer your changes. You don’t want to make a mistake and break your site, since that brings down the editor as well. But for simple adds/edits, it’s OK – I do it that way, too.

        This does bring up a good idea though – it might make sense to add a custom code snippets section for the plugin. A lot of themes have this type of process. As I mentioned, this isn’t really necessary since that functionality is already there, but it’s something I’ll think about.

        Hope that helps.

        • October 7, 2014 at 10:53 am #6043
          amca
          Participant

          Wow, thanks for the quick and elaborated answer!

          It makes completely sense. I will try it out.

          • October 7, 2014 at 11:06 am #6044
            Chad Butler
            Keymaster

            No problem – I don’t usually say this out loud, but I tend to get through the easiest questions first 😉

            And if you run into any problems, let me know.

        • February 6, 2015 at 4:15 am #7136
          bentupper
          Participant

          Also, since it’s mentioned in the comments here, perhaps an extension could be created for Custom Code Snippets. Something that, as you explain it, doesn’t require an entirely separate plugin, but could help those users who don’t want to mess with functions.php editing.

          With such a handy feature as this (multiple check boxes) I vote it be added to the priority items list of the development roadmap.

          Can I get a +1 on that anybody else? Chad, what say you?

          Thanks.

          • February 6, 2015 at 10:31 am #7140
            Chad Butler
            Keymaster

            Thanks for the kind words and suggestions. As always, it’s great to get positive feedback on the plugin and the site.

            Yeah – I am in the process of doing a content audit on the site as there are some things that are a little dated. I tend to be a “digital hoarder” so nothing ever gets thrown out. But often times (as you’ll discover) I write up a tutorial on how to do something and it can become quite popular (which is good) generating a lot of questions and ideas from users that I didn’t originally think of. Most of the time, this leads to additional posts with more spin-offs. I try to keep up with noting this in the original post, but there are definitely some posts hiding in the site that I need to update or redirect. It’s an ongoing process.

            Your suggestion about code snippets is actually quite timely. I have been thinking of how to incorporate a process into the plugin’s options for storing and loading custom functions. I know there are themes that do this to avoid having users mess with the functions.php file, so I thought, why not here? Especially since the code snippet library has grown so much – it would be easier for the average users (I think). And if I did it right, it would prevent an inexperienced user from crashing their site because they missed a comma or something.

            On that note, as some of the code snippets mature and evolve, those lead to becoming an extension for the plugin. Kind of like Schoolhouse Rock’s “I’m just a bill, sittin’ here on Capitol Hill” if you’re old enough to remember that – the bill grows up to become a law – well, here code snippets grow up to become extensions. Or, in the case of the User List, that might grow up from an extension to become its own plugin.

            The one I’m working on right now is adding the Honey Pot to the Blacklist extension. The honey pot is the best way to fight registration spam and I think it makes sense to include this in the extension that is focused on security issues. I know that digresses way off topic but I think it’s sometimes good to give a discussion of my development philosophy.

    • February 6, 2015 at 4:06 am #7134
      bentupper
      Participant

      Hi Chad,

      I just signed up and I’m pretty stoked about this plugin’s powers. I’m doing something on a site I’m developing that requires multiple checkboxes and I was just reading this post about it. Thankfully I scanned down the entire page and read through all comments to date as well. I see you have a newer post on this topic – (https://rocketgeek.com/filter-hooks/multiple-selection-checkboxes-2/). For others, like myself, who are reading about this topic for the first time, could you put the Multiple Selection Checkboxes 2 link at the top of this (Multiple Selection Checkboxes) post so everybody will be directed to the most up to date information? Just a humble suggestion.

      Thanks for such a cool plugin! Looking forward to all the possibilities it will deliver!!

  • Author
    Posts
Viewing 8 reply threads
  • You must be logged in to reply to this topic.
Log In

Primary Sidebar

Forgot?  Register

Topics

  • Actions
  • Basics
  • Blog
  • Design
  • Download Protect
  • Filters
  • How I Did It
  • MailChimp
  • Release Announcements
  • Shortcodes
  • Templates
  • Tips and Tricks
  • Uncategorized
  • User List
  • User Tracking
  • WooCommerce

Recent Posts

  • WP-Members User List 2.0.1 release
  • WP-Members Download Protect version 1.7.0
  • WP-Members Security 1.3.0
  • WP-Members 3.3.8 Update
  • Patch file available for password reset issues

Tags

actions add_action basics bug-fix css demo email filters forms free get_avatar get_currentuserinfo hooks is_page is_user_logged_in mailchimp menus paypal registration release-notes security shortcodes str_replace template_redirect the_content tips user-list utility wp-filters wpdb wpmem_admin_after_block_meta wpmem_admin_block_meta_save wpmem_block wpmem_login_form wpmem_member_links wpmem_post_register_data wpmem_post_update_data wpmem_pre_register_data wpmem_register_data wpmem_register_form wpmem_register_form_rows wpmem_securify wpmem_sidebar_form wpmem_sidebar_status wp_mail

Ready to get started?

Join Today!

© 2021 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Refund Policy