Skip to Content Skip to Menu

Generate unique alias with Auto Actions

  • aalisg
  • aalisg
  • OFFLINE
  • Posts: 108
  • Thanks: 8
  • Karma: 0
7 hours 12 minutes ago #344582 by aalisg
Hello,We are using Community Builder with CB Auto Actions 9.5.0 and would like to automatically generate an opaque public profile alias for every newly registered user.The goal is to have profile URLs such as:
Code:
/member-a7c29f81d4.html
instead of exposing the Joomla username in the profile URL.We created a CB Auto Action with the following configuration:
  • Trigger:
    Code:
    onBeforeUserRegistration
  • Action type: Field
  • Field: Alias
  • Operator: Set (field = value)
  • Value:
    Code:
    [cb:parse function="code"]return 'member-' . bin2hex(random_bytes(5));[/cb:parse]
  • Save directly: No
  • User: empty (triggering user)
  • Format Code Function: enabled
  • Reference Variable: Variable 1 (
    Code:
    &$user
    )
  • Display: No
The PHP format function itself should return a value such as
Code:
member-a7c29f81d4
, but after registration the user's Alias field is still empty.We also tested without using the Reference Variable, with the same result.Could you please advise what the supported way is to populate the built-in Alias / Profile URL field automatically during CB registration?In particular:
  1. Is
    Code:
    onBeforeUserRegistration
    the correct trigger for this?
  2. Can the Field action modify the built-in
    Code:
    alias
    field at this stage?
  3. Should Save directly be enabled or disabled?
  4. Which Reference Variable, if any, should be used?
  5. Is there a different CB trigger specifically intended for setting the profile alias before the user is stored?
Our objective is simply to generate a unique, non-personal, non-guessable profile URL automatically for each new account.Thank you.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 50727
  • Thanks: 8694
  • Karma: 1475
4 hours 44 minutes ago #344586 by krileon
Replied by krileon on topic Generate unique alias with Auto Actions
The field action triggers a user store. Either on the object or via query (if using direct set). The user doesn't exist yet during onBeforeUserRegistration. You need to use onAfterUserRegistration instead. It should then immediately work.


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: beat, nant, krileon
Powered by Kunena Forum