1

I need to find out in php if 'the current user' has recently renewed membership (or just signed up as a new member).

I don't think I can get data about renewal from the Membership entity. The 'Join date' seems to be the same as the 'Start date'. So for renewal, I'd have to look at Activities of the type renewal.

  • I hoped I could do this with the ActivityContact entity, but it doesn't allow me to filter on activity type.
  • I hoped I could do this with the Activity entity, but it doesn't allow me to filter on the 'target_contact', or 'assignee', or whatever it's called.

So .. do I need to join api calls - how would I do that ? - or is there another way ?

2
  • I'm wading through the api as usual; hammering php, looking at old forum messages or figuring out the unit tests, running through the source code on github. Or I can test things here d46.demo.civicrm.org/civicrm/api/explorer .. but there is no demo for 4.5. /Rant.
    – commonpike
    Dec 1, 2015 at 16:56
  • Powered by CiviCRM 4.5.3
    – commonpike
    Dec 1, 2015 at 16:56

2 Answers 2

1

Why not check against membership status New? The length of time it's New from and for is configurable I believe.

Personally I'd try to use the API with a get command. If the API for this didn't work on the install that I was working on, I would write a custom SQL query for CRM_Core_DAO. Happy to help you further with that if needed.

3
  • Membership status New doesn't work for recent renewals. For new members, it would work, and I already have code to do that.
    – commonpike
    Dec 2, 2015 at 11:35
  • The api works fine. It's the api explorer that has never worked here (and in several other installations).
    – commonpike
    Dec 2, 2015 at 11:36
  • I'd like to stay away from sql .. when i say 'join queries' i mean join api calls.
    – commonpike
    Dec 2, 2015 at 11:40
0

After a brand new update, the api explorer works fine. And the answer is, in PHP

$result = civicrm_api3('Activity', 'get', array(
  'sequential' => 1,
  'activity_type_id' => array('IN' => array("Membership Signup", "Membership Renewal")),
  'activity_date_time' => array('>' => time()-30*24*60*60),
  'source_contact_id' => $contactid,
));
$recent = ($result['count']>0);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.