Answers.Body: <p>After a brand new update, the api explorer works fine. And the answer is, in PHP</p>
  
  <pre><code>$result = civicrm_api3('Activity', 'get', array(
    'sequential' =&gt; 1,
    'activity_type_id' =&gt; array('IN' =&gt; array("Membership Signup", "Membership Renewal")),
    'activity_date_time' =&gt; array('&gt;' =&gt; time()-30*24*60*60),
    'source_contact_id' =&gt; $contactid,
  ));
  $recent = ($result['count']&gt;0);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-25T12:15:54.917Z
Answers.LastActivityDate: 2016-10-25T12:15:54.917Z
Answers.UserDisplayName: commonpike
Answers.Body: <p>Why not check against membership status New? The length of time it's New from and for is configurable I believe.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-02T11:35:45.103Z
Answers.Text: Membership status New doesn't work for recent renewals. For new members, it would work, and I already have code to do that.
Answers.UserDisplayName: commonpike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-02T11:36:30.527Z
Answers.Text: The api works fine. It's the api explorer that has never worked here (and in several other installations).
Answers.UserDisplayName: commonpike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-02T11:40:01.923Z
Answers.Text: I'd like to stay away from sql .. when i say 'join queries' i mean join api calls.
Answers.UserDisplayName: commonpike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-01T22:23:06.053Z
Answers.LastActivityDate: 2015-12-01T22:23:06.053Z
Answers.UserDisplayName: JohnFF
Body: <p>I need to find out in php if 'the current user' has recently renewed membership (or just signed up as a new member).</p>
  
  <p>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.</p>
  
  <ul>
  <li>I hoped I could do this with the ActivityContact entity, but it
  doesn't allow me to filter on activity type. </li>
  <li>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.</li>
  </ul>
  
  <p>So .. do I need to join api calls - how would I do that ? - or is there another way ?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-01T16:56:14.937Z
Comments.Text: 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 http://d46.demo.civicrm.org/civicrm/api/explorer .. but there is no demo for 4.5. /Rant.
Comments.UserDisplayName: commonpike
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-01T16:56:44.730Z
Comments.Text: `Powered by CiviCRM 4.5.3`
Comments.UserDisplayName: commonpike
Tags: <civimember><api><activity>
Title: api: Get renewal activity for a contact
ThreadText: # api: Get renewal activity for a contact
  
  (Asked by: username_0 on 2015-12-01)
  
  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 ?
  
  **Tags:** civimember, api, activity
  
  > **Comments:**
  > **username_0**: 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 http://d46.demo.civicrm.org/civicrm/api/explorer .. but there is no demo for 4.5. /Rant.  
  > **username_0**: `Powered by CiviCRM 4.5.3`  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2016-10-25. Score: 0 | Accepted answer
  
  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);
  
  
  ---
  
  ### Answer by username_1 on 2015-12-01. Score: 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.
  
  > **Comments:**
  > **username_0**: Membership status New doesn't work for recent renewals. For new members, it would work, and I already have code to do that.  
  > **username_0**: The api works fine. It's the api explorer that has never worked here (and in several other installations).  
  > **username_0**: I'd like to stay away from sql .. when i say 'join queries' i mean join api calls.  
  
  ---
  
  