• Resolved spannerz

    (@spannerz)


    Hello folks,

    I’m having issues regarding dates during the Import process.
    Well, I’m trying to fix dates I broke the first time round, since a lot of them were reversed since my CSV had dates in UK format of dd/mm/yyyy and the months were reversed and it expired a load of my members.

    I have built a CSV containing the correct mebership_startdate and membership_enddate values but there are issues with the way the Import from CSV and PMPro Import from CSV handle NULL values for my Memberships that have no expiry date.

    Currently, if I have anything other than a date in the future set, the Membership is expired with todays date as the enddate.
    I have tried NULL, “NULL”, “Never”, 0000-00-00 and leaving the cell blank. I have a CSV tool called CSVED which is very useful for all sorts of CSV operations, and I’ve tried that since I read that Excel doesn’t actually treat a blank cell as NULL.

    I am currently looking at the pmpro-import-users-from-csv.php file with this section of code:

    		//if membership was in the past make it inactive
    		if($membership_status === "inactive" || (!empty($membership_enddate) && $membership_enddate !== NULL && strtotime($membership_enddate, current_time('timestamp')) < current_time('timestamp')))
    		{			
    			$sqlQuery = "UPDATE $wpdb->pmpro_memberships_users SET status = 'inactive' WHERE user_id = '" . $user_id . "' AND membership_id = '" . $membership_id . "'";		
    			$wpdb->query($sqlQuery);
    			$membership_in_the_past = true;
    		}
    		
    		if($membership_status === "active" && (empty($membership_enddate) || $membership_enddate === NULL || $membership_enddate === "Never" || $membership_enddate === "0000-00-00" || strtotime($membership_enddate, current_time('timestamp')) >= current_time('timestamp')))
    		{			
    			$sqlQuery = $wpdb->prepare("UPDATE {$wpdb->pmpro_memberships_users} SET status = 'active' WHERE user_id = %d AND membership_id = %d", $user_id, $membership_id);		
    			$wpdb->query($sqlQuery);
    		
    		}
    	}

    I have a CDV with these headings :
    membno id user_login first_name last_name user_email membership_id membership_initial_payment membership_billing_amount membership_cycle_number membership_cycle_period membership_status membership_startdate membership_enddate AnniversaryDate AnniversaryMonth PackIssued CardIssued card membership_year Comments
    The headings in Italic are my custom fields and they work fine.

    I need the import to register a Membership as non-expiring, without it setting the endddate to 1970-01-01 or 0000-00-00 and setting the status to “inactive” & the orders to “cancelled”

    If I can just get the import to read a NULL text value as NULL for mySQL that would cure it 🙂

    Any ideas, folks?

    Regards,
    Simon

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Fixing data via CSV’ is closed to new replies.