Skip to Content Skip to Menu

Pre-fill field in profile before Profile Edit Displays

  • kdave321
  • kdave321
  • ONLINE
  • Posts: 191
  • Thanks: 24
  • Karma: 1
2 years 6 months ago - 2 years 6 months ago #329254 by kdave321
I created an auto-action to set a custom field in #__comprofiler as the user's profile is editted.

It seemed like the trigger "onBeforeUserProfileEditDisplay" would be what I want but what happens is the Profile Edit form comes up with it undefined. I checked the field in the table and the auto-action update worked - the field is correctly set. If I cancel the edit and then return to it, the field is set.
Last edit: 2 years 6 months ago by kdave321. Reason: typo

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 6 months ago #329263 by krileon
Usually it's best to establish defaults as early as possible. This typically means during registration. Ideally on onAfterUserRegistration trigger with a Field action. You should only need to do this for fields not displayed on registration though since the "Default Registration Value" parameter can be used if visible on registration.

If you really want to do this on onBeforeUserProfileEditDisplay then the below should work.

Global
Triggers: onBeforeUserProfileEditDisplay
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: FIELD_NAME
Operator: Is Empty
Action
Method: PHP
Code:
Code:
$variables['var1']->set( 'FIELD_NAME', 'FIELD_VALUE' );
Parameters
References: Variable 1

FIELD_NAME should be whatever field you're wanting this to apply to. FIELD_VALUE should be whatever value you want to set it to. This should just directly let you modify the user object before profile edit form behavior without storing anything to the database yet. Then when they save profile edit it will store the change.


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: kdave321

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

Moderators: beatnantkrileon
Powered by Kunena Forum