TOPIC:

Access Owner Object 4 months 2 weeks ago #247665

  • Topic Author
  • paolo.procacciante
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 118
  • Thanks: 0
Hello,
I'd like to know how can I access to the owner object of a saved record.
Thanks
PP

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

Access Owner Object 4 months 2 weeks ago #247671

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 10064
  • Karma: 167
  • Thanks: 807
Hi,

if the user has been logged in when doing a form submission, his user id is stored in #__facileforms_records

You can use this ID to programmatically retrieve the Joomla user object (at least that's what's the Joomla API docs are saying):
// $id previously retrieved from the record
echo JFactory::getUser($id)->get('username');

If you need the user on-the-fly while he is doing a submission, you can also use the above without $id in a submit or form piece (=php) for each individual form of yours.

Regards,
Markus

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

Access Owner Object 4 months 2 weeks ago #247674

  • Topic Author
  • paolo.procacciante
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 118
  • Thanks: 0
Thanks Markus,
basically I'm creating a plugin that can hide or show some parts on contentbuilder based on joomla user group (so I can assign manually users who can read or not particular area) and I'd like as default to let owner access his/her document.
Any idea?

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

Access Owner Object 4 months 2 weeks ago #247677

  • Topic Author
  • paolo.procacciante
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 118
  • Thanks: 0
I found this below similar that works only on joomla content

private function processAuthor($text) {
// Search for this tag in the content
$regex = "#{author}(.*?){/author}#s";

$userId = JFactory::getUser()->id;
$isAuthor = (isset($this->article->created_by) && $this->article->created_by == JFactory::getUser()->id ? true : false);

$text = preg_replace_callback($regex, function ($match) use ($isAuthor) {
return $isAuthor ? $match[1] : '';
}, $text);

return $text;
}

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

Access Owner Object 4 months 2 weeks ago #247733

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 10064
  • Karma: 167
  • Thanks: 807
Hi,

cool, then you just need to work with this
JFactory::getUser()->get('id');

and compare the user id from the above with the user id from the record in BF.

Regards,
Markus

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

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.048 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!