Get Vendor's Administrator Id

Hi all!

Does anyone know how to obtain the cscart_users.user_id of the user who is currently logged in vendor adminstration (from php code)?

$Session[auth] is only reflecting customer not admin.

Looking forward to your answer.

Best regards

hummer

Hello

[auth] => Array
(
[area] => A
[user_id] => 5
[user_type] => V

..........

$_SESSION['auth'] contain user_id vendor admin as see above.

Best regards

Robert

Hi Robert,

thanks for that quick reply. I think I have to explain more in detail what I am doing.

Vendor Tab "iFrame Test" opens an iFrame with source to an "own" PHP page (in root directory www/cscart/).

Code in this page is currently:

define(‘AREA’, ‘A’);
require(dirname(FILE) . ‘/init.php’);

echo ‘

’ . print_r($_SESSION, TRUE) . ‘
’;

?>

But session[auth] is showing customer data (see screenshot). Do you know why?

[attachment=14707:iframe_test_tab.PNG]

Looking forward to your answer.

Best regards

hummer

iframe_test_tab.PNG

Hello

When preparing an iframe link, you can pass user_id as a parameter. You can do it by adding in template e.g.
&vendor_user_id=$smarty.session.auth.user_id
NOT TESTED.
Best regards
Robert

Cool idea, Robert!

But I can only pass static URL parameters as it is an Add-On. It allows to attach an iFrame to a vendor tab with a static URL only.

[attachment=14708:iframe_test_tab2.PNG]

Is there no chance to get access from my.php to the CS-Cart environment (and $Session[auth])?

Best regards

hummer

iframe_test_tab2.PNG

Hello

But you have to use this link somewhere. So you can type my.php?section = 123&vendor_user_id=[user_id] or whatever. And in the template, do a parsing of this link and substitute the necessary value from session.

Best regards

Robert

Ah, understood!

Stated the link with placeholder "[user_id]" as proposed in the backend add-on configuration:

/../my.php?section=123&vendor_user_id=[user_id]

Changed the template code from

[...] src="{$field.values|trim}" [...] 

to

[...] src="{$field.values|trim|replace:"[user_id]":$smarty.session.auth.user_id}" [...] 

Get of URL querystring "vendor_user_id" on my.php works!

Thank you!

But: this was an modification in the Add-On template. Is there a way not to perform this change directely in the Add-On template (e.g. via Mychanges Add-On)?

Best regards

hummer

Hello

If the template doesn't have a hook, you can override template in for example my_changes addon or add your own hook if you don't want to overwrite it. But must remember that you added a hook and if the updates overwrite the template you will have to restore the hook.

Best regards

Robert