Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Pulling member info

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Tweaks › Pulling member info

  • This topic has 16 replies, 7 voices, and was last updated 13 years, 4 months ago by admin.
Viewing 15 posts - 1 through 15 (of 17 total)
1 2 →
  • Author
    Posts
  • August 6, 2011 at 1:49 pm #3989
    Missy
    Member

    Hi,

    I am looking to create a custom member list using a template file (I can’t use the include public list shortcode as I need company name vs. user name)

    Usually I can connect to the WP database using something like

    <?php
    global $wpdb;
    $myrows = $wpdb->get_row("SELECT * FROM $wpdb->wp_eMember_members_tbl");

    echo $myrows->company_name;
    ?>

    I have tried a ton of different variations of the above and can not seem to pull records, what am I missing?

    August 7, 2011 at 1:43 am #35230
    amin007
    Participant

    The syntax is wrong. The table name is a string field. Also you are getting one row from many rows in the database where is your “condition” so it knows which row to pick based on that condition?

    August 7, 2011 at 4:47 am #35231
    Missy
    Member

    LOL…honestly that was my just my latest attempt I was just trying to pull anything by then…I tried a bunch, at this point I had knocked all of my code to a simple pull just to see if I could connect, once I am pulling the records I can code out everything else, basically I want to pull all level 3 members, ordered by company name, and echo just the company name…just need a basic list at this point

    Eventually I want to link the company name to work similar to the member list shortcode opening a lightbox with the companies info…but I can get there once I can pull from the table

    August 7, 2011 at 4:50 am #35232
    Missy
    Member

    I have only pulled info from the WP tables…first time pulling from a plugins table

    Initially I think I had…

    $user_ids = $wpdb->get_col("SELECT member_id FROM $wpdb->wp_eMember_members_tbl ORDER BY company_name");

    echo $user_ids->company_name;

    August 7, 2011 at 11:39 pm #35233
    amin007
    Participant

    Your table name is definitely wrong. You can’t access the eMember table name using the following since it not an object of the WPDB class.

    $wpdb->wp_eMember_members_tbl

    Try the following to get a feeling for how it works then you should be able to do more specific things:

    global $wpdb;
    $members_table_name = $wpdb->prefix . "wp_eMember_members_tbl";
    $resultset = $wpdb->get_results("SELECT * FROM $members_table_name", OBJECT);
    print_r($resultset);

    August 9, 2011 at 3:31 am #35234
    Missy
    Member

    THANKS!!

    I was able to get my list with this:

    <?php
    global $wpdb;
    $members_table_name = $wpdb->prefix . "wp_eMember_members_tbl";
    $resultsets = $wpdb->get_results("SELECT * FROM $members_table_name", OBJECT);

    foreach ($resultsets as $member):

    ?>
    <?php if($member->membership_level == 3) { ?>
    <li><?php echo $member->company_name; ?></li>

    <?php
    }
    endforeach;
    ?>

    August 12, 2011 at 11:29 pm #35235
    Missy
    Member

    Back again…and almost there, hoping you may have some advice for me…I have listed my members by company name, turned them into links that when clicked open a modal overlay in jquery…but I am a complete novice in jquery and have no idea how to pass values from php and vice versa, so currently my overlay comes up but only displays the info for the first member record…thought you might have an idea since the shortcode list uses an overlay…AGAIN THANKS!!! Love the support you provide for your users who want to go offroading!!! lol

    <h2>List of Members:</h2>
    <script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>

    <ul>

    <?php
    global $wpdb;
    $order = 'company_name';
    $members_table_name = $wpdb->prefix . "wp_eMember_members_tbl";
    $resultsets = $wpdb->get_results("SELECT * FROM $members_table_name ORDER BY $order", OBJECT);

    foreach ($resultsets as $member):

    ?>

    <?php if($member->membership_level == 3) { ?>

    <li><a href="#" class="modalInput" rel="#profile2" ?>"><?php echo $member->company_name; ?></a>
    </li>

    <!-- Profile Overlay -->
    <div class="modal2" id="profile2">

    <h2><?php echo $member->company_name; ?></h2>
    <dl>
    <dt>Address:</dt>

    <dd><?php echo $member->address_street; ?>
    <?php echo $member->address_city; ?> ,Fl
    <?php echo $member->address_zipcode; ?></dd>

    <dt>Phone Number:</dt>
    <dd><?php echo $member->phone; ?></dd>

    </dl>

    <!-- close button -->
    <p>
    <button class="close"> Close </button>
    </p>
    </div>

    <script>

    $(document).ready(function() {

    var triggers = $(".modalInput").overlay({

    // mask tweaks
    mask: {
    color: '#ebecff',
    loadSpeed: 200,
    opacity: 0.9
    },

    closeOnClick: false
    });

    });

    </script>

    <?php
    }
    endforeach; //
    ?>

    </ul>

    September 2, 2011 at 11:50 pm #35236
    akeith2002
    Member

    How would you get the current logged in user’s membership info INCLUDING all custom registration fields ?!?

    September 4, 2011 at 8:24 pm #35237
    akeith2002
    Member

    I got this going:

    <?php

    global $auth;

    $user_id = $auth->getUserInfo('member_id');

    if (!empty($user_id))

    {

    global $wpdb;

    $members_meta_table_name = $wpdb->prefix . "wp_members_meta_tbl";

    $resultset = $wpdb->get_results("SELECT meta_value FROM $members_meta_table_name WHERE user_id = $user_id", OBJECT);

    print_r($resultset);

    }

    ?>

    but it is returning the data in the way wordpress stores it:

    a:3:{s:6:"Gender";s:4:"Male";s:26:"Date_of_Birth__MM/DD/YYYY_";s:2:"es";s:5:"Sport";s:6:"Hockey";}

    How do I further decipher that?

    September 4, 2011 at 8:56 pm #35238
    akeith2002
    Member

    Sorry I figured it out.

    unserialize();

    October 27, 2011 at 12:54 pm #35239
    thomasbrunkard
    Member

    akeith2002 : Would you be able to share your code with me? I’m trying to create custom pages that display all data a user has (including custom fields). My problem comes in with the custom fields part – how do you decipher that serialized data?

    Cheers!

    October 27, 2011 at 10:06 pm #35240
    admin
    Keymaster

    Use the unserialize() function and it will put the serialized data in a nice array that you can use. For example:

    $custom_fields_arry = unserialize("serialized-custom-data");
    print_r($custom_fields_arry);

    January 8, 2012 at 5:35 pm #35241
    sol
    Member

    Hi,

    just to say that this post was great to figure out what I needed. Here is how I used and adapted it – watch out that you change the membership level to be displayed if you want to have a different one then 2. If you put it into a page, you also need to have a wordpress php plugin like php exec installed.

    <div align=”center”>

    <div>

    <table>

    <thead>

    <tr>

    <td align=”center”>

    <div>Surname</div></td>

    <td align=”center”>

    <div>First name</div></td>

    <td align=”center”>

    <div>Company</div></td>

    <td align=”center”>

    <div>Country</div></td>

    </tr>

    </thead>

    <tbody>

    <?php

    global $wpdb;

    $order = ‘company_name’;

    $members_table_name = $wpdb->prefix . “wp_eMember_members_tbl”;

    $resultsets = $wpdb->get_results(“SELECT * FROM $members_table_name ORDER BY $order”, OBJECT);

    foreach ($resultsets as $member):

    ?>

    <?php if($member->membership_level == 2) { ?>

    <tr>

    <td align=”left”><?php echo $member->last_name; ?></td>

    <td align=”left”><?php echo $member->first_name; ?></td>

    <td align=”left”><?php echo $member->company_name; ?></td>

    <td align=”left”><?php echo $member->country; ?></td>

    </tr>

    <?php

    }

    endforeach; //

    ?>

    </tbody>

    </table>

    </div>

    </div>

    January 17, 2012 at 6:40 am #35242
    pachoolee
    Member

    I followed the posts above, but I am still having problems displaying/utilizing the custom fields.

    Here is the code:

    if (!empty($user_id)) {

    global $wpdb;

    $members_meta_table_name = $wpdb->prefix . “wp_members_meta_tbl”;

    $metadata = $wpdb->get_results(“SELECT meta_value FROM $members_meta_table_name WHERE user_id = $user_id”, OBJECT);

    // print_r($metadata);

    $unsermetadata = unserialize($metadata);

    }

    I get this warning:

    Warning: unserialize() expects parameter 1 to be string, array given

    The print_r returns:

    Array ( [0] => stdClass Object ( [meta_value] => a:4:{s:15:”I_need_one”;s:7:”checked”;s:10:”Cell_Phone”;s:9:”219999999″;s:10:”Sponsor_ID”;s:1:”2″;s:10:”Sponsee_ID”;s:0:””;} ) )

    January 18, 2012 at 4:44 am #35243
    admin
    Keymaster

    If you are not a PHP developer then take advantage of the shortcodes that lets you display any details of the logged in user. For example, the following shortcode will display the email address of the logged in member:

    [wp_eMember_user_details user_info="email"]

    You can use the above shortcode to display the custom fields too.

    Check the shortcodes page for more details:

    http://www.tipsandtricks-hq.com/wordpress-membership/wp-emember-shortcodes-and-functions-reference-124

  • Author
    Posts
Viewing 15 posts - 1 through 15 (of 17 total)
1 2 →
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ