Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] CB auto action within the same line javascript and PHP

8 years 2 months ago - 8 years 2 months ago #284246 by smalldragoon
ello
I have CB auto actions install and I'm tryting to install a device fingerprinting solution at login

I have the following code, tested out of Joomla which works :

<?php $MyREFSessionID = md5(microtime(true)); ?>

Hello
I have CB auto actions install and I'm trying to install a device fingerprinting solution at login

I have the following code, tested out of Joomla which works :
Code:
<?php $MyREFSessionID = md5(microtime(true)); ?> <sscript type="text/javascript" src="http://xxxxx/device.js?myrefsession_id=<?php echo $MyREFSessionID ?>&debug=1"></script>


note : the sscript is normal as otherwise, forum do not allow me to put sample code and interpret it ...


I created an auto-action at "before login" with a code action
I'm fine with the first php line, but how can I have the 2nd working ?
I made some test with HTML or Javascript and it is not working ....
Thanks a lot !


I created an auto-action at "before login" with a code action
I'm fine with the first php line, but how can I have the 2nd working ?
I made some test with HTML or Javascript and it is not working ....
Thanks a lot !
Last edit: 8 years 2 months ago by krileon. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #284256 by krileon
There's no output during that trigger. This means the JS you're trying to echo will never do anything because that trigger is mid-PHP action. If you need that code to be output in the login form it self you should be using the below trigger.

onAfterLoginForm

With this trigger you need to return an array of data however, which for your usage should probably be as follows.

Code:
$return = 'YOUR_HTML_HERE'; return array( 'beforeForm' => $return );

This should output your HTML before the login form.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

8 years 2 months ago - 8 years 2 months ago #284305 by smalldragoon
Hello
Thanks for the answer
Why using the array ?

Using this code works, but the code is executed several time ... is the array makes the difference ?

$MyREFSessionID = md5(microtime(true));


$return = '<sscript type="text/javascript" src="https://xxxx?session_id='. $MyREFSessionID .'&debug=1">';
return ( $return);

Thx !
Last edit: 8 years 2 months ago by smalldragoon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #284309 by krileon

Why using the array ?

Well you don't have to, but for the case of the login module it's how you determine where your HTML will output in the module otherwise it default outputs after the login/logout button. I guess it doesn't particularly matter for your usage.

Using this code works, but the code is executed several time ... is the array makes the difference ?

It's going to output with every login module. So if you've multiple login modules it will output several times. You may want to just consider making it a part of your templates HTML if you need it output guaranteed only once.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

8 years 2 months ago - 8 years 2 months ago #284328 by smalldragoon
Hi
Ok , understood, it explains why it is run multiple times I guess.

using

return array( 'beforeForm' => $return )

only write " in clear" Array, array, array ( as text, part of the page I can read ) , as per the attachment


I don't get it... I guess I'm missing the philosophy of it to understand it ?
Thx
Attachments:
Last edit: 8 years 2 months ago by smalldragoon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #284348 by krileon
The return setting for your code action should be Return. I'm guessing you've it set to Echo.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum