Reputation: 528
I'm using the splash module, but I'm not getting the results I want. I'd to show a lightbox presentation for when the user first logs in. I'm probably going to write a custom template that prints to a block, and then dynamically display the block based on a certain condition.
I'm working with cookies, and here is some calls I'm working with:
if (!$cookie_data['time']) {
print $block;
} else { }
Very basic, but I just basically want to write a condition that checks if it's the user's first visit.
*UPDATE: Okay. This was my mistake, I need it to be able to do it only for Anonymous users. My bad. Here is the code I'm using, but it isn't working sufficiently...
function custommodule_init() {
setcookie('splash_status',$splash_status,time()+3600*24*365);
if (!isset($_COOKIE['splash_status'])) $_COOKIE['splash_status'] = 0;
$splash_status = $_COOKIE['splash_status'] + 1;
if ($splash_status > 1) {
drupal_add_js(drupal_get_path('module', 'sbasplash') . '/sbasplash.js');
drupal_add_css(drupal_get_path('module', 'sbasplash') . '/sbasplash.css');
// Action to enable block
} else {
// Action to disable block
}
}
Upvotes: 2
Views: 682
Reputation: 1
Also, make sure your custom module is set to run after the splash module. You can set the weight
value in the system
table of your module to above that of the splash, making sure the cookie is always set before your code checks for it.
Upvotes: 0
Reputation: 6282
By default I think there s no drupal api to detect first login , we need a custom code , perhaps a new column attribute set to status = 1 , in hook_user for login check if status = 1 if status is 1 then display splash page and make status 0 so that next time no splash page comes up.
Upvotes: 0
Reputation: 517
Create a custom module, implement "hook_user" and insert your code in the "insert" operation. When a user gets inserted into the database for the first time, your code will be executed. You can use it to add a your block or set a session variable and display your block according to its value.
yourcustommodule_user($op, &$edit, &$account, $category = NULL) {
switch($op){
case 'insert':
//your code here
//example: $_SESSION['show_block'] = 1; and then unset after block is shown
break;
}
}
Upvotes: 1