This mod modifies GTCustom Pages, you can download it here:
GTCustom Pages - Create Custom Pages With Ease
More information here:
Create Custom Pages
I was working on a quick project and there was 3 buy now buttons that needed to show up only for members who are logged in.
With a little modification to this hack you can do this:
First find or download goto.php that comes with this package and open it with your favourite text editor.
Find:
PHP Code:
/*
* *************************************
* PHRASES - no need to parse
* **************************************
*/
$vbphrase['content'] = $vbphrase['gtcustom_' . $section];
$vbphrase['header_title'] = $vbphrase['gtcustom_' . $section . '_header'];
$vbphrase['sub_title'] = $vbphrase['gtcustom_' . $section . '_subtitle'];
It starts at line: 70
Add these lines after them:
PHP Code:
/**
* User logged in stuff
* By Codehead @ talk.code-head.com
**/
if( isset($vbphrase['gtcustom_' .$section .'_user_not_logged_in']) && strlen($vbphrase['gtcustom_' .$section .'_user_not_logged_in']) > 0 && !$vbulletin->userinfo['userid'] ) {
$regex = '#__START_USER_SECTION__.*?__END_USER_SECTION__#is';
$vbphrase['content'] = preg_replace($regex, $vbphrase['gtcustom_' .$section .'_user_not_logged_in'], $vbphrase['content']);
} else {
$regex = array('#__START_USER_SECTION__#i', '#__END_USER_SECTION__#i');
$vbphrase['content'] = preg_replace($regex, '', $vbphrase['content']);
}
So all together it will look like this:
PHP Code:
/*
* *************************************
* PHRASES - no need to parse
* **************************************
*/
$vbphrase['content'] = $vbphrase['gtcustom_' . $section];
$vbphrase['header_title'] = $vbphrase['gtcustom_' . $section . '_header'];
$vbphrase['sub_title'] = $vbphrase['gtcustom_' . $section . '_subtitle'];
/**
* User logged in stuff
* By Codehead @ talk.code-head.com
**/
if( isset($vbphrase['gtcustom_' .$section .'_user_not_logged_in']) && strlen($vbphrase['gtcustom_' .$section .'_user_not_logged_in']) > 0 && !$vbulletin->userinfo['userid'] ) {
$regex = '#__START_USER_SECTION__.*?__END_USER_SECTION__#is';
$vbphrase['content'] = preg_replace($regex, $vbphrase['gtcustom_' .$section .'_user_not_logged_in'], $vbphrase['content']);
} else {
$regex = array('#__START_USER_SECTION__#i', '#__END_USER_SECTION__#i');
$vbphrase['content'] = preg_replace($regex, '', $vbphrase['content']);
}
Upload it back to your server.
Then you need another phrase called:
gtcustom_YOUR_CUSTOM_PAGE_user_not_logged_in
And put the text for when the user is not logged in or not a memeber, for instance:
(HTML alowed)
HTML Code:
You must be logged in to purchase this item.<br />
Please take a moment to login or register.
Then in your gtcustom_YOUR_CUSTOM_PAGE phrase wrap the sections in __START_USER_SECTION__ & __END_USER_SECTION__ for instance:
HTML Code:
Some info about the item that you want to sell...
__START_USER_SECTION__
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
...
</form>
__END_USER_SECTION__
Some other item info...
__START_USER_SECTION__
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
...
</form>
__END_USER_SECTION__
You can have multiple sections for logged in users and if they are not logged in, the text in gtcustom_YOUR_CUSTOM_PAGE_user_not_logged_in will be shown.