aMember 4: Multi Select in Profile Form

Discussion in 'Customization & add-ons' started by 19dozen, Apr 2, 2012.

  1. 19dozen

    19dozen New Member

    Joined:
    Nov 15, 2010
    Messages:
    6
    Hi there,

    I've not quite got my head around aMember4 yet. I am wanting to make a form with just multiple checkboxes in and display that on a single page within Wordpress. I have already added a field for this and I want the aMember field manager to manage the fields that are allowed in to the form. How would I go about doing this?
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    I believe there are many questions, not just one. Step by step:

    1. Multiple checkboxes? What is it about? I guess about product selection.
    Go to aMember CP -> Forms Editor -> click Edit and click "configure" on "Products" brick.

    2. Display signup form in wordpress. aMember does not become a part of wordpress, but it may look like it is.
    Configure Wordpress plugin in aMember according to manual, and enable "Use WordPress theme" at aMember CP -> Setup -> Wordpress. In this case aMember user-side pages will be displayed inside your WP theme.
    Then open URL http://yoursite.com/amember/signup - it is your signup page.

    3. If you want to add a custom field to user profile, go to aMember CP -> Add Fields, and define the field. Field will be added to user profile. Then to add field to signup form, use aMember CP -> Forms Editor -> edit again. There will be a spare brick at right named as your custom field. Drag it to left into the form, and Save.
  3. 19dozen

    19dozen New Member

    Joined:
    Nov 15, 2010
    Messages:
    6
    Hi Alex,

    Thanks for the response. Not quite what I'm after I'm afraid.

    As part of the website we are developing, members can affiliate themselves with local groups. These local groups are not set up as products because we didn't want people to have to 'order' them. That process is being kept purely for the subscription. What I have done is add a field (aMember CP -> Add Fields) with a multi-select box as I want people to be able to go to the 'Local Groups' page and select which groups they want to belong to. This also gives the administrators the ability to alter this in aMember it's self.

    What I really need to know is where the possible values for the field I have created are stored. I could then use those in my 'Local Groups' code to draw the form and populate it with the correct information from aMember. That way, when they change a value in the back end of aMember, the same value is changed on the front end.
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Custom fields settings are stored in the big config array.

    You can fetch it like:

    $q = mysql_query("SELECT config FROM am_config LIMIT 1");
    $r = mysql_fetch_row($q);
    $config = unserialize($r[0]);
    var_dump($config['member_fields']);
    print_r($config['member_fields']['yourfieldname']);
  5. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    I'd anyway recommend to use products (create free products!) to track this, this will simplify everything you do with these customers - emailing, protect content, search, reporting, simply anything.
  6. 19dozen

    19dozen New Member

    Joined:
    Nov 15, 2010
    Messages:
    6
    Thank you for that. this is what I ended up with in Wordpress:

    $sql = "SELECT * FROM am_config LIMIT 1";
    $config = $wpdb->get_row( $sql );
    $optionsArray = $config['member_fields'][25]['additional_fields']['options'];

    $output .= '<select name="localgroups[]" multiple="multiple">';

    foreach($optionsArray as $key => $value){
    $output .= "<option value=\"$key\">$value</option>";
    }

    $output .= '</select>';

    The problem that we have with the local groups is that they want to have multiple websites across multiple domains, all controlled from a single aMember install. The sites are all part of the same group, you see, so the members are identical but some of them appear in one site and some in another, depending on their choice of group (which they can change whenever they want).

    The members list and profile pages are easily pulled from the database with our custom code and I have even worked out how to limit the group they are being pulled from but all of the logins happen on the main site only.

    Anyway, I've got that bit working in the way I wanted. All I have to do now is pull in the user data with:

    $sql = "SELECT * FROM am_user WHERE login = '".$current_user->user_login."' ";
    $result = $wpdb->get_row( $sql );

    Although I'm having a problem with the $current_user variable at the moment.

Share This Page