CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Update Membership Record script
Pages: [1]

Author Topic: Update Membership Record script  (Read 3786 times)

case

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
Update Membership Record script
January 12, 2008, 03:23:03 pm
We have just started to use the update membership record script running from a cron job to send out renewal notices. It's working fine, with the exception of inserting blank lines for tokens that do not have a value, but I do have a question about it.

1. It appears to drop a numbered text file in the root directory of our server each time it runs. I'm assuming this is because the cron job runs as the user 'root'. Can I change that by using 'su' before the script runs?

2. But more importantly, the report never tells us anything. It just basically lets us know that it has run even when I know that a renewal email has been sent out. The content of the message is:

Updating ......................................................................
................................................................................
.......

 Membership records updated. (Done)

It would be much more helpful if the script did not put it's report in the root directory and if the report contained information on what members were sent a renewal reminder. It might even be helpful if we could have any message sent out copied to an administrative address. We did that with previous software that we used and it was nice to have an archive containing copies of the actual messages that went out.

Can this be accomplished?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Update Membership Record script
January 12, 2008, 08:43:44 pm

1. are you running the cron job via wget/curl? If so, it should not be creating any files at the root level. (the web server would not allow it). if not, what version of civicrm are you using? You should redirect the cron output to a log file and check for any error messages in that file periodically (good cron practice). The numbered text file is a side effect of your cron process

2. You'll need to make some manual changes to enable point two. The changes are fairly trivial and we can walk you thru them on IRC. If you file an issue, we'll resolve it in a 2.x release

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

case

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
Re: Update Membership Record script
January 13, 2008, 03:20:39 am
Quote from: Donald Lobo on January 12, 2008, 08:43:44 pm

1. are you running the cron job via wget/curl?

Here's my cron entry (which i added when logged in as root to our server):

00 2 * * * /usr/bin/wget 'http://www.case.org.au/administrator/components/com_civicrm/civicrm/bin/UpdateMembershipRecord.php' 2>&1 | mailx -s "Membership Database Daily Update Report" membership@case.org.au 2>&1

2. You'll need to make some manual changes to enable point two. The changes are fairly trivial and we can walk you thru them on IRC. If you file an issue, we'll resolve it in a 2.x release

I can wait for ver 2. No need to hassle you on IRC about it.

Thanks.

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Update Membership Record script
May 27, 2008, 01:14:03 pm
case,
just ran across your post. I made some mods to the update membership script to include some meaningful info about the records impacted. see attached in case it's helpful (it's a little messy).

Note that there's also a change in this file to send out the reminder notice on the reminder date AND the end date. you'll want to change back if that's not something you want.
-Brian
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

shakey

  • Guest
Re: Update Membership Record script
May 31, 2008, 09:07:31 pm
If I do not want to have an email sent, will the standard script update the membership statuses if I delete the following lines?

Code: [Select]
            //send reminder for membership renewal
            if ( $dao->reminder_date &&
                 ( $dao->reminder_date <= $today ) ) {
                $memType =& new CRM_Member_BAO_MembershipType( );
                $memType->id = $dao->membership_type_id;
                if ( $memType->find( true ) &&
                     $memType->renewal_msg_id ) {
                    $toEmail  = CRM_Contact_BAO_Contact::getPrimaryEmail( $dao->contact_id );

                    if ( $toEmail ) {
                        // Set the FROM email address for reminder emails here.
                        // This must be a valid account for your SMTP service.
                        $from = "abc@def.com";
                        CRM_Member_BAO_MessageTemplates::sendReminder( $dao->contact_id,
                                                                       $toEmail,
                                                                       $domainID,
                                                                       $memType->renewal_msg_id,
                                                                       $from);

                        //Set membership reminder date to NULL since we've sent the reminder.
                        crm_update_contact_membership( array('id'             => $dao->membership_id,
                                                             'reminder_date'  => 'null' ) );

                                 
                        //insert the log record.
                        $memb = new CRM_Member_BAO_Membership( );
                        $memb->id = $membership->id;
                        if ( $memb->find( true ) ) {
                            //insert the log record.
                            $membershipLog =& new CRM_Member_BAO_MembershipLog( );
                            $membershipLog->membership_id = $memb->id;
                            $membershipLog->status_id   = $memb->status_id;
                            $membershipLog->start_date  = CRM_Utils_Date::customFormat($memb->start_date,'%Y%m%d');
                            $membershipLog->end_date    = CRM_Utils_Date::customFormat($memb->end_date,'%Y%m%d');
                            $membershipLog->modified_id = $dao->contact_id;
                            $membershipLog->modified_date = date("Ymd");
                            $membershipLog->renewal_reminder_date = date("Ymd");
                            $membershipLog->save( );
                            $membershipLog->free( );
                        }
                        $memb->free( );
                    }
                }
                $memType->free( );
               
            }

-Thanks

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Update Membership Record script
June 02, 2008, 02:35:22 pm
An email will only be sent if you've configured the membership type to have an email sent. You don't need to modify the update membership script. Go to the membership type config screen and review the settings at the bottom of the page.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Laryn

  • I post frequently
  • ***
  • Posts: 192
  • Karma: 4
    • CEDC
  • CiviCRM version: 4.6.x
  • CMS version: Drupal 7
Re: Update Membership Record script
June 30, 2008, 09:25:25 am
Is there an official update to this script to email the results (with names of emailed members and other info) to an administrator?

I see the patched script here has some specific modifications for a Joomla db, is that right? Does it do what I am asking about above?

I'm running Drupal, but I imagine the Civi databases should be the same?

Thanks,
lpkb
CEDC...social justice by design

*Get support on the new CiviCRM help site. /laryn

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Update Membership Record script
June 30, 2008, 09:55:07 am
This is emphatically not "official." It was just provided to get people started adding some additional info to the update script.

It is not joomla-specific. The joomla references are just the db name (I meant to strip that from the file and leave it generic).

Also -- the script itself doesn't email to the admin. Most cron job tools have an option to email the cron output to an email. What this does is ensure that the output from the cron includes details on which records were update.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Update Membership Record script

This forum was archived on 2017-11-26.