- Forum
- Products
- Vodes
- No credits still shows content. Need to check balance and redirect to purchase.
No credits still shows content. Need to check balance and redirect to purchase.
- producerman1
- Topic Author
- Offline
- New Member
Less
More
- Thank you received: 0
15 years 3 months ago #4810
by producerman1
Hey guys,
I need to know what to add to check Vodes balance and redirect for Vodes purchase. When a user clicks on the link to the page, as of now, if there are credits it will deduct. But if there are "0" credits the link still allows the view to occur. I have tried a few of the "if" examples around the threads but nothing works correctly. I get errors related to the line I tried to code. I am sure it is a simple thing. Any help would be great.
I used the example code from your threads at the top of the target page.:
Code used:
<?php
defined('_JEXEC') or die('Restricted access');
$user = & JFactory::getUser();
$path = JPATH_SITE.DS.'components'.DS.'com_vodes'.DS.'models'.DS.'credits.php';
require_once($path);
$credits =& new VodesModelCredits();
$credits->_user = $user;
$credits->decrease(2);
}
if "WHAT DO I NEED HERE TO CHECK BALANCE and REDIRECT IF 0 BALANCE"
}
else if "WHAT GOES HERE IF BALANCE AVAILABLE TO SHOW CONTENT?"
?>
Thanks so much in advance for your help.
Best wishes,
PM1
I need to know what to add to check Vodes balance and redirect for Vodes purchase. When a user clicks on the link to the page, as of now, if there are credits it will deduct. But if there are "0" credits the link still allows the view to occur. I have tried a few of the "if" examples around the threads but nothing works correctly. I get errors related to the line I tried to code. I am sure it is a simple thing. Any help would be great.
I used the example code from your threads at the top of the target page.:
Code used:
<?php
defined('_JEXEC') or die('Restricted access');
$user = & JFactory::getUser();
$path = JPATH_SITE.DS.'components'.DS.'com_vodes'.DS.'models'.DS.'credits.php';
require_once($path);
$credits =& new VodesModelCredits();
$credits->_user = $user;
$credits->decrease(2);
}
if "WHAT DO I NEED HERE TO CHECK BALANCE and REDIRECT IF 0 BALANCE"
}
else if "WHAT GOES HERE IF BALANCE AVAILABLE TO SHOW CONTENT?"
?>
Thanks so much in advance for your help.
Best wishes,
PM1
Please Log in or Create an account to join the conversation.
- Saka
- Offline
- Administrator
15 years 3 months ago - 15 years 3 months ago #4811
by Saka
Emir Sakic
www.sakic.net
if ($credits->balance()<=0) {
// redirect
global $mainframe;
$mainframe->redirect('index.php?option=com_vodes', 'Buy credits!');
} else {
// continue to show content
}
Emir Sakic
www.sakic.net
Last Edit: 15 years 3 months ago by Saka.
Please Log in or Create an account to join the conversation.
- producerman1
- Topic Author
- Offline
- New Member
Less
More
- Thank you received: 0
15 years 3 months ago #4812
by producerman1
Hey Saka,
Thanks so much!
Works as expected.
Best wishes,
PM1
Thanks so much!
Works as expected.
Best wishes,
PM1
Please Log in or Create an account to join the conversation.