ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Print Member Screen Name Based on Custom Field Selection

November 15, 2012 5:08pm

Subscribe [2]
  • #1 / Nov 15, 2012 5:08pm

    jaredw

    13 posts

    In the Members Module, I have created several custom SELECT fields for a member profile, with the option of YES, ALTERNATE, or NO. When a member edits their profile and selects YES for a custom field, I’d like to have a page list all the members by “screen_name” that selected YES for that custom field.  This would be a public page, no login requirement needed to see the page.

    What’s the best way to print the screen_name based on the custom field selection?

  • #2 / Nov 16, 2012 1:34pm

    Rob Allen

    3108 posts

    Are you using the stock member profile templates, or using an addon such as Solspace User?

  • #3 / Nov 16, 2012 3:38pm

    glenndavisgroup

    436 posts

    Your best option is to use the query tag for this so you can filter the info based on what you need. But you will have to do some digging in the EE db in the exp_member_data and exp_member_field tables to figure out the custom field names to use in the query. Your query would look something like this:

    {exp:query limit="30" paginate="bottom" 
       sql="SELECT m.member_id, m.screen_name, m.username, md.mm_field_id_1 as 'first_name', md.mm_field_id_2 as 'last_name'
     FROM exp_members m,`exp_member_data` md
     where md.member_id = m.member_id
       and m.member_id > 1
       and md.m_field_id_3 = 'yes'
     order by 1"}
    
    ...your html & EE code here like
    {member_id}
    {screen_name}
    {first_name}
    {last_name}
    ...
    {/exp:query}

    The field references in the query above for “md.mm_field_id_1”, “md.mm_field_id_2”, and “md.mm_field_id_3” would refer to your custom fields you created in your members profile. These are the column names you need to get from the exp_member_data table that correspond to the custom fields you created. You will be able to figure out the column names by looking at exp_member_fields and exp_member_data and mapping the ids to get the right field(s). I hope I explained this correctly.

    Thank you,

    Mike

  • #4 / Nov 19, 2012 3:55pm

    Dan Decker

    7338 posts

    Hi jaredw,

    Using the Custom Profile Data tag makes this pretty straight forward:

    {exp:member:custom_profile_data}
    {if custom_select == 'YES'}
    Display data you want
    {/if}
    {/exp:member:custom_profile_data}

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases