Answers.Body: <p>Have you confirmed that the Scheduled Job which updates Membership Status is enabled. You have made a bit jump in civi versions and I don't think Scheduled Jobs was around in 4.0.x</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-11T04:54:06.410Z
Answers.Text: I tried it but it doesn't work that way either.
Answers.UserDisplayName: Shreyas.Telkar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-08T21:21:07.103Z
Answers.LastActivityDate: 2017-09-08T21:21:07.103Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>I have a page where the membership payment and different contribution amounts are displayed through a price set to collect member dues for one month.</p>
  
  <p>I was using civicrm 4.0.5 previously and now I am using civicrm 4.7.17</p>
  
  <p>Everything worked perfectly fine on civicrm 4.0.5.</p>
  
  <p>However, in civicrm 4.7.17, after the payments are made the Membership expiry dates do not advance.</p>
  
  <p>So I wrote my own code to advance the membership expiry date to the last day of the next month. Here is the code:</p>
  
  <pre><code>//get the membership dates for the cid                                                                                                                                    
    $membership_get_params = array(
      'version' =&gt; 3,
      //specify the membership type id                                                                                                                                        
      'membership_type_id' =&gt; $membership_type_id,
      'contact_id' =&gt; $objectRef-&gt;contact_id,
      'filters' =&gt; array(
        'is_current' =&gt; 1,
      ),
    );
    require_once 'api/api.php';
    $membership_get_result = civicrm_api( 'membership','get',$membership_get_params);
    $membership_get_result = $membership_get_result['values'][$membership_get_result['id']];
  
    // Find date of next month                                                                                                                                                
    $end_date = $membership_get_result['end_date'];
    $end_date_array = explode('-', $end_date);
    $year = $end_date_array[0];
    $month = $end_date_array[1];
    $day = $end_date_array[2];
    if (in_array($objectRef-&gt;contribution_page_id, $one_month_contribution_page_ids)) {
      $next_month = $month + 1;
    }
  
    if ($next_month &gt; 12) {
      $year = $year + 1;
      $next_month = $next_month - 12;// Get next month if payment for member dues goes beyond the current year                                                                
    }
    $date = $year . '-' . $next_month . '-1';
    $next_month_end_date = new DateTime($date);
    $next_month_end_date = $next_month_end_date-&gt;format( 'Y-m-t' );
  
    $excludeIsAdmin = false;
  
    $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate( $membership_get_result['start_date'], $membership_get_result['end_date'], $membership_get_resul\
  </code></pre>
  
  <p>t['join_date'], 'today', $excludeIsAdmin );</p>
  
  <pre><code>  // Save expiry date for membership for contact                                                                                                                            
    $membership_create_params = array(
      'id' =&gt; $membership_get_result['id'],
      'contact_id' =&gt; $objectRef-&gt;contact_id,
      'membership_type_id' =&gt; $membership_type_id,
      'start_date' =&gt; $membership_get_result['start_date'],
      'join_date' =&gt; $membership_get_result['join_date'],
      'end_date' =&gt; $next_month_end_date,
      'status_id' =&gt; $calcStatus['id'],
      'version' =&gt; 3,
    );
  
    Logger::debug_var("membership_create_params", $membership_create_params);
  
    require_once 'api/api.php';
    $result = civicrm_api( 'membership', 'create', $membership_create_params );
  </code></pre>
  
  <p>Is this the optimal solution??</p>
  
  <p>If not, please suggest.</p>
  
  <p>Thanks in advance.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-07T02:40:48.287Z
Comments.Text: You haven't said if your Contributions are being set to Completed or not. That would be one reason Memberships don't get renewed. Generally writing your own code to fix something that is known to work in CiviCRM means you are probably doing a workaround for something else that is not configured correctly such as the payment processor sending info back to civi
Comments.UserDisplayName: petednz - fuzion
Tags: <civimember>
Title: Membership Expiry Date not advancing after membership payments
ThreadText: # Membership Expiry Date not advancing after membership payments
  
  (Asked by: username_0 on 2017-09-08)
  
  I have a page where the membership payment and different contribution amounts are displayed through a price set to collect member dues for one month.
  I was using civicrm 4.0.5 previously and now I am using civicrm 4.7.17
  Everything worked perfectly fine on civicrm 4.0.5.
  However, in civicrm 4.7.17, after the payments are made the Membership expiry dates do not advance.
  So I wrote my own code to advance the membership expiry date to the last day of the next month. Here is the code:
  //get the membership dates for the cid                                                                                                                                    
    $membership_get_params = array(
      'version' => 3,
      //specify the membership type id                                                                                                                                        
      'membership_type_id' => $membership_type_id,
      'contact_id' => $objectRef->contact_id,
      'filters' => array(
        'is_current' => 1,
      ),
    );
    require_once 'api/api.php';
    $membership_get_result = civicrm_api( 'membership','get',$membership_get_params);
    $membership_get_result = $membership_get_result['values'][$membership_get_result['id']];
  
    // Find date of next month                                                                                                                                                
    $end_date = $membership_get_result['end_date'];
    $end_date_array = explode('-', $end_date);
    $year = $end_date_array[0];
    $month = $end_date_array[1];
    $day = $end_date_array[2];
    if (in_array($objectRef->contribution_page_id, $one_month_contribution_page_ids)) {
      $next_month = $month + 1;
    }
  
    if ($next_month > 12) {
      $year = $year + 1;
      $next_month = $next_month - 12;// Get next month if payment for member dues goes beyond the current year                                                                
    }
    $date = $year . '-' . $next_month . '-1';
    $next_month_end_date = new DateTime($date);
    $next_month_end_date = $next_month_end_date->format( 'Y-m-t' );
  
    $excludeIsAdmin = false;
  
    $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate( $membership_get_result['start_date'], $membership_get_result['end_date'], $membership_get_resul\
  
  t['join_date'], 'today', $excludeIsAdmin );
    // Save expiry date for membership for contact                                                                                                                            
    $membership_create_params = array(
      'id' => $membership_get_result['id'],
      'contact_id' => $objectRef->contact_id,
      'membership_type_id' => $membership_type_id,
      'start_date' => $membership_get_result['start_date'],
      'join_date' => $membership_get_result['join_date'],
      'end_date' => $next_month_end_date,
      'status_id' => $calcStatus['id'],
      'version' => 3,
    );
  
    Logger::debug_var("membership_create_params", $membership_create_params);
  
    require_once 'api/api.php';
    $result = civicrm_api( 'membership', 'create', $membership_create_params );
  
  Is this the optimal solution??
  If not, please suggest.
  Thanks in advance.
  
  **Tags:** civimember
  
  > **Comments:**
  > **username_1**: You haven't said if your Contributions are being set to Completed or not. That would be one reason Memberships don't get renewed. Generally writing your own code to fix something that is known to work in CiviCRM means you are probably doing a workaround for something else that is not configured correctly such as the payment processor sending info back to civi  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-09-08. Score: 0
  
  Have you confirmed that the Scheduled Job which updates Membership Status is enabled. You have made a bit jump in civi versions and I don't think Scheduled Jobs was around in 4.0.x
  
  > **Comments:**
  > **username_0**: I tried it but it doesn't work that way either.  
  
  ---
  
  