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 Code Field blocking back-end user edit

8 years 6 months ago - 8 years 6 months ago #280290 by uperformro
:S
If you have code fields defined, trying to edit a user in the back end produces:

Fatal error: Call to undefined function fictitiousFunction() in <span>/</span>home<span>/</span>xxx/public_html/yyy/components/com_comprofiler/plugin/user/plug_cbcodefield/templates/default/display.php(34) : runtime-created function on line 5

Could you possibly ask the developers to NOT try to process code fields when editing a user in the back end (at /administrator/index.php?option=com_comprofiler&view=edit) ?

It's just so silly to have to constantly disable the code field plug-in each time you want to view/edit a user profile. That's the only work-around we've found at least -- which makes front-end functions not work, so kinda annoying.

Thanks!
Last edit: 8 years 6 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 6 months ago - 8 years 6 months ago #280297 by krileon
Replied by krileon on topic Cb Code Field blocking back-end user edit
There's nothing wrong with CB Code Field working in backend. The error is happening in your code it self. The function you're trying to execute doesn't exist or wasn't defined properly. I do not recommend putting large blocks of code there. If you need a large amount of code you should do so through a separate PHP file and simply include it. The below examples work fine in my tests.

Function:
Code:
function test() { return 'PASS!'; } return test();

Simple:
Code:
return 'PASS!';

Also ensure CB Code Field is up to date.


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.
Last edit: 8 years 6 months ago by krileon.
The following user(s) said Thank You: uperformro

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

8 years 6 months ago - 8 years 6 months ago #280374 by uperformro
Replied by uperformro on topic Cb Code Field blocking back-end user edit
Yup, you were right Kyle -- we had some functions in profiler pro (which are included in each profile in the front end) which were not included in the back-end.

Did some rewrites to set the hikashop/hikamarket values into CB on update -- so can use the native $user->hikashopvalue in CB now instead of doing a query into hikashop for the value. Double the storage, but that's life!

Thanks so much!

Editing -- just had a thought -- would there be a way to "inject" a function or two into back end using a code field so it could be used by other code fields?

We'd want to put in something like:


function getMagazinFld($getFld, $thisFld, $ifFld, $ifValue) {

//first get the hikashop user id

Global $_CB_framework;

//$myId = $_CB_framework->myId();
//$cbUser =& CBuser::getInstance( $myId );

$displayedUser = $_CB_framework->displayedUser();

$cbUser =& CBuser::getInstance( $_CB_framework->displayedUser() );

if ( ! $cbUser ) {
$cbUser =& CBuser::getInstance( null );
}

$user =& $cbUser->getUserData();

$displayedUserCmsID = $user->user_id;

$db = JFactory::getDbo();
$cmsuser =& JFactory::getUser();
$userid = $cmsuser->get('id');

$query = $db->getQuery(true);
$query->select('user_id');
$query->from($db->quoteName('upr_hikashop_user'));
$query->where($db->quoteName('user_cms_id')." = ".$db->quote($displayedUserCmsID));

$db->setQuery($query);
$hikashopuserid = $db->loadResult();


$db = JFactory::getDbo();

$query = $db->getQuery(true);
$query->select($getFld);
$query->from($db->quoteName('upr_hikashop_user'));
$query->where($db->quoteName('user_id')." = ".$db->quote($hikashopuserid).' AND '.$db->quoteName($ifFld)." = ".$db->quote($ifValue));

$db->setQuery($query);
$fieldValue = print_r($db->loadResult(), true);
$returnFld = '<span class="'.$thisFld.' '.$getFld.'-'.$fieldValue.' '.$fieldValue.'">'.$fieldValue.'</span>';
return $returnFld.'';
}


End of the day, we'd LOVE if you and hika could get together sometime, at least to put an end to the double-user-profile situation ... I have to do UPDATES on every user profile save both in CB and Hika to get the things coordinated. Bit of a pain!

Cheers!
Last edit: 8 years 6 months ago by uperformro. Reason: code example

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 6 months ago #280455 by krileon
Replied by krileon on topic Cb Code Field blocking back-end user edit

Editing -- just had a thought -- would there be a way to "inject" a function or two into back end using a code field so it could be used by other code fields?

Possibly with a Code action in CB Auto Actions acting on onBeforeUserProfileEditDisplay.

End of the day, we'd LOVE if you and hika could get together sometime, at least to put an end to the double-user-profile situation ... I have to do UPDATES on every user profile save both in CB and Hika to get the things coordinated. Bit of a pain!

They would need to implement support for CB getFields API to output CB fields instead of their fields. We already support their fields via Code or Query field as it fits both API based and database based usages.


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.
The following user(s) said Thank You: uperformro

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

8 years 6 months ago #280494 by uperformro
Replied by uperformro on topic Cb Code Field blocking back-end user edit
Kyle -- thanks so much for the CB Auto Actions hint -- I'm dumb, forgot about that. Worked perfectly. I moved all my get-from-hikashop functions there.

And yes, you're quite right, access via API in Code and Query fields works okay for us really. Obviously requires a bit of php/sql knowledge ... but we continue to be very impressed with the flexibility and power provided by Community Builder's conditional, code, query and auto action capabilities.

Thanks so much!
The following user(s) said Thank You: nant, krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum