WordPress.org

Ready to get started?Download WordPress

Forums

Paid Memberships Pro
[resolved] PMP export CSV, call in PODs user field (3 posts)

  1. codzprc
    Member
    Posted 1 year ago #

    As a non-paying (I'm a broke self-employed designer) PMP user, I've been directly editing PMP's pages PHP to do my evil bidding, and display custom User fields from the PODs plugin.

    For example, I made a User field named student_name, that I wanted to display in my PMP member's list and printout in the "Export CSV" option (That's my issue, but we'll get to that)

    Here's how to do the first part:

    Pods > create new user pod > Label whatever > name(mine is student_name)

    Then I opened PMP's Memberslist.php and added the 3rd line below (ctrl+f the second line to see where to put it)

    <td><?php echo $metavalues->first_name?></td>
    <td><?php echo $metavalues->last_name?></td>
    <td><?php echo get_user_meta( $theuser->ID, 'podfield_name', true ); ?></td>

    Don't forget to add a column in the spreadsheet! (Again, add the last line, and serach for any of the other's)

    <tr class="thead">
    				<th>ID</th>
    				<th>Username</th>
    				<th>First&nbsp;Name</th>
    				<th>Last&nbsp;Name</th>
    				<th>Student&nbsp;Name</th>

    Now for my current problem

    I'd like to pull that same data into the CSV as it exports, and memberslist-cvs.php does things a little differently - it took me 2 weeks of searching to figure out the first part (remember, I said I'm a designer, not a developer:), so now I'm asking for help.

    I've added a column to the CSV export php (student name again, creates column in spreadsheet)
    $csvoutput = "id,username,firstname,lastname,student name,email,billing firstname,

    but membership-csv.php uses an array to call in data, which looks like this

    //these are the meta_keys for the fields (arrays are object, property. so e.g. $theuser->ID)
    	$default_columns = array(
    		array("theuser", "ID"),
    		array("theuser", "user_login"),
    		array("metavalues", "first_name"),
    		array("metavalues", "last_name"),

    I'm new with PHP, I don't know where or how I need to call in the PODs field, but nothing I've tried has worked.

    Tried this:
    $student = get_user_meta( $theuser->ID, 'student_name', true );

    with a few different array values

    array("theuser", "student_name"),
    //and tried
    array("metavalues", "student_name"),
    //and tried
    array("theuser", "student_name"),
    //and tried
    array($student),

    Any and all help appreciated, and I hope the first part helped someone.

    http://wordpress.org/extend/plugins/paid-memberships-pro/

  2. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    That looks right, but I've never used PMP myself. Pods fields work like other fields, get_user_meta should just, "work."

  3. codzprc
    Member
    Posted 1 year ago #

    I got it working, and I'm embarrassed to say the answer was really simple and obvious. I'm assuming pods stores the additional fields right in the user meta - because all I did to fix the issue was call metavalues instead of theuser, like so

    //these are the meta_keys for the fields (arrays are object, property. so e.g. $theuser->ID)
    	$default_columns = array(
    		array("theuser", "ID"),
    		array("theuser", "user_login"),
    		array("metavalues", "first_name"),
    		array("metavalues", "last_name"),
    		array("metavalues", "student_name"),

    That's the only change that was needed and presto!

    Here's the part of memberslist-csv.php that I edited, guess this is all it takes.

    //add student name column after last name
    $csvoutput = "id,username,firstname,lastname,student name,email,billing firstname,billing lastname,address1,address2,city,state,zipcode,country,phone,membership,initial payment,fee,term,joined,expires";
    
    	//these are the meta_keys for the fields (arrays are object, property. so e.g. $theuser->ID)
    	$default_columns = array(
    		array("theuser", "ID"),
    		array("theuser", "user_login"),
    		array("metavalues", "first_name"),
    		array("metavalues", "last_name"),
    		array("metavalues", "student_name"),
    		array("theuser", "user_email"),
    		array("metavalues", "pmpro_bfirstname"),
    		array("metavalues", "pmpro_blastname"),
    		array("metavalues", "pmpro_baddress1"),
    		array("metavalues", "pmpro_baddress2"),
    		array("metavalues", "pmpro_bcity"),
    		array("metavalues", "pmpro_bzipcode"),
    		array("metavalues", "pmpro_bzipcode"),
    		array("metavalues", "pmpro_bcountry"),
    		array("metavalues", "pmpro_bphone"),
    		array("theuser", "membership"),
    		array("theuser", "initial_payment"),
    		array("theuser", "billing_amount"),
    		array("theuser", "cycle_period")
    		//joindate and enddate are handled specifically below
    	);

    Didn't even need the $student = get_user_meta( $theuser->ID, 'student_name', true );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic