I am trying to adapt the hide bock so only admin users can see the template elements
The link to the tutorial is here:
function smarty_block_oxhideblock( $params, $content, &$smarty , &$repeat)
Hey,
I dont have any skills at any of this, but try this insted:
function smarty_block_oxhideblock( $params, $content, &$smarty , &$repeat)
{
$userid = oxSession::getVar( ‘auth’ );
if (!$repeat && !$userid) {
return ‘’;
}
return $content;
}
searched around a bit and that might work. but i have no idea
Unfortunately this does not work
[QUOTE=gnomic;115926]Hey,
I dont have any skills at any of this, but try this insted:
searched around a bit and that might work. but i have no idea :)[/QUOTE]
http://docu.oxid-esales.com/CE/sourcecodedocumentation/4.4.5.31315/oxsupercfg_8php_source.html
isAdmin() ?
I have already tried many random entries from search results, but they did not work, I am afraid i am gonna need an advise from somebody who has some experience beyond googling for random code, but thanks anyway
[QUOTE=gnomic;115929]http://docu.oxid-esales.com/CE/sourcecodedocumentation/4.4.5.31315/oxsupercfg_8php_source.html
isAdmin() ?[/QUOTE]
if( oxSession::getVar(‘usr’) == ‘oxdefaultadmin’ )
Yes, this works indeed, thank you very much.
The problem for me is that only one account is allowed by the oxid system to be set as default admin, I have tried in the data base to set some other accounts to defaultadmin (oxsuser table, oxid column) but the system does not allow to do that.
Is there a way to assign more then one account to defaultadmin status?
[QUOTE=Hebsacker;115941]if( oxSession::getVar(‘usr’) == ‘oxdefaultadmin’ )[/QUOTE]
try ‘malladmin’ instead
these are all users marked as “admin” in backend
They are not the same, look at the screen shot, I have tried to change other malladmin accounts to defauladmin in the database, but error came up - not allowed
Ther default admin is account id, it can not be identical to otehr id’s.
Is it possible to adopt hide code to malladmin instead of default, changing like this does not work:
$userid = oxSession::getVar( ‘usr’ ) == ‘malladmin’;
[QUOTE=Hebsacker;115957]try ‘malladmin’ instead
these are all users marked as “admin” in backend[/QUOTE]
Does somebody know how to charge this code for malladmin users?
function smarty_block_oxhideblock( $params, $content, &$smarty , &$repeat)
{
$userid = oxSession::getVar( ‘auth’ );
if (!$repeat && !$userid) {
return ‘’;
}
return $content;
}
please use the common
BB-Code Tags for code wrapping, your "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" wrapping does not work on smartphones
[IMG]http://i48.tinypic.com/2a61pv6.jpg[/IMG]
in Template you can use this code:
[{if $oxcmp_user && $oxcmp_user->oxuser__oxrights->value eq ‘malladmin’}]only for admin[{/if}]
if you want to use this code in php you will need to get the active user object first and then check his oxrights
There is no template for this, it is functioning based on single php file, unfortunately for me I do not know anything about php programing, but if I understand correctly the code line:
$userid = oxSession::getVar( ‘usr’ ) == ‘oxdefaultadmin’;
means that condition is true when the oxid id = oxdefaultadmin
my question is:
assume some other oxid id is -> 469c822222222261cfd
then what is the correct way in php formulating this condition:
$userid = oxSession::getVar( ‘usr’ ) == ‘oxdefaultadmin [B]or[/B] 469c822222222261cfd’;
[QUOTE=vanilla thunder;116129]please use the common
BB-Code Tags for code wrapping, your "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" wrapping does not work on smartphones
[IMG]http://i48.tinypic.com/2a61pv6.jpg[/IMG]
in Template you can use this code:
[{if $oxcmp_user && $oxcmp_user->oxuser__oxrights->value eq ‘malladmin’}]only for admin[{/if}]
if you want to use this code in php you will need to get the active user object first and then check his oxrights[/QUOTE]
Code below works for only one account, how to adopt it so it works for 5 accounts:
function smarty_block_oxhideblock( $params, $content, &$smarty , &$repeat)
{
$userid = oxSession::getVar( ‘usr’ ) == ‘oxdefaultadmin’;
if (!$repeat && !$userid) {
return ‘’;
}
return $content;
}
whose 5 accounts in the data base looks like this (please see atachement):
Hi stasysd,
the following code should work for all admin users.
function smarty_block_oxhideblock( $params, $content, &$smarty , &$repeat)
{
$oUser = oxNew('oxuser');
$oUser->loadActiveUser();
if ($repeat && $oUser->oxuser__oxrights->value == "malladmin") {
return $content;
}
return '';
}
Thanks for the code, it looks like a way to the right direction but it still does not return hidden content for neither of the situations: no login, regular user login, oxdefaultadmin login, malladmin login.
would it be possible to look through the code again to get it work?
[QUOTE=sirius205;116564]Hi stasysd,
the following code should work for all admin users.
function smarty_block_oxhideblock( $params, $content, &$smarty , &$repeat)
{
$oUser = oxNew('oxuser');
$oUser->loadActiveUser();
if ($repeat && $oUser->oxuser__oxrights->value == "malladmin") {
return $content;
}
return '';
}
[/QUOTE]
$oUser should give you the information you want.
Try to change the if-statement like this: (I do not think that $repeat is necessary in the statement)
if ($oUser->oxuser__oxrights->value == "malladmin") {
If this does not work I would like to see the code where you are calling the function “smarty_block_oxhideblock” from and the path to the file the function is saved in.
Thank you sirius205, I cleaned the code as you suggested, and it works now exactly, as I wanted - only admin users are able to see the code after they login. Now I can display some information for admins only, like actual stock levels, etc. thanks again for your help.
this is the code that works:
function smarty_block_oxhideblock( $params, $content, &$smarty)
{
$oUser = oxNew('oxuser');
$oUser->loadActiveUser();
if ($oUser->oxuser__oxrights->value == "malladmin") {
return $content;
}
return '';
}
[QUOTE=sirius205;116608]$oUser should give you the information you want.
Try to change the if-statement like this: (I do not think that $repeat is necessary in the statement)
if ($oUser->oxuser__oxrights->value == "malladmin") {
If this does not work I would like to see the code where you are calling the function “smarty_block_oxhideblock” from and the path to the file the function is saved in.[/QUOTE]