Welcome, Guest
Username Password: Remember me

birthday rule based on joomla user profile data
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: birthday rule based on joomla user profile data

birthday rule based on joomla user profile data 1 year, 9 months ago #20709

Not sure if I'm off topic here, anyway I just wanna share a little mod I made to the official happy birthay rule so that the check it's made from the joomla (2.5.x) user profile data instead that from the alphauserpoints user data.

install the happy birthay rule, than edit the file plugins/user/sysplgaup_happybirthday/sysplgaup_happybirthday.php

first replace the query (line 36):
$query = "SELECT id FROM #__alpha_userpoints WHERE userid='".intval($instance->get('id'))."' AND birthdate!='0000-00-00'";


width:
$query = "SELECT profile_value FROM #__user_profiles WHERE user_id='".intval($instance->get('id'))."' AND profile_key='profile.dob' AND profile_value!='\"0000-00-00\"'";



than replace the check method (from line 42 to 47):
$year = date('Y');	
// check if birthday today
$query = "SELECT id FROM #__alpha_userpoints WHERE userid='".intval($instance->get('id'))."' AND DATE_FORMAT(birthdate, '%-%m-%d')=DATE_FORMAT(NOW(), '%-%m-%d');";
$db->setQuery( $query );
$happybirthday = $db->loadResult();
if ( $happybirthday ) 


width:
$birthdate = str_replace( '"' , '', $birthdate ); // strips double quotes from the db result
$year = date('Y');
$today = date('m-d');
$happybirthday = substr_compare( $birthdate, $today , 5, 5 ); // check if birthday today
				
if ( $happybirthday === 0 ) // if it's 0 and not null


the check it's made directly with the php function substr_compare() instead that from mysql DATE_FORMAT comparison because joomla stores the user profile data type as a VARCHAR and contains double quotes.

That's it. hope could be usefoul to someone. cya.

Re: birthday rule based on joomla user profile data 1 year, 9 months ago #20717

  • Bernard
  • OFFLINE
  • Administrator
  • Posts: 3173
  • Karma: 110
Thanks for this good post.
More components on this site are free but...
Ever thought about giving something back?
Please make a donation if you want to support its continued development. Your donations help by hardware, hosting services and other expenses.

Re: birthday rule based on joomla user profile data 1 year, 4 months ago #21566

  • piersol
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Points: 73
  • Karma: 0
This requires the client to login ON there exact birthday to get the points. How can we make it award the points on their next visit AFTER there birthday.

Re: birthday rule based on joomla user profile data 1 year, 4 months ago #21570

piersol wrote:
This requires the client to login ON there exact birthday to get the points. How can we make it award the points on their next visit AFTER there birthday.


Actually I don't have the project to test it right now, so I cannot post the correct lines of code as a "patch", anyway if u know a bit about php u can just replace the date check with:
 if( strtotime( $birthdate ) > strtotime('now') ) 

paying attenction that the format of the string $birthdate fits the strtotime() requirements.
  • Page:
  • 1
Moderators: adroussel, dalekurt, migus, some1new
Time to create page: 0.44 seconds
Goto Top