Skip to Content Skip to Menu

[SOLVED] Modify Cell number to include default country code

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 7 months ago - 8 years 7 months ago #289149 by fribse2011
Hi Guys

I'm trying to make a small auto action that will modify the entered cell number if people don't enter +xx code for country before their cell number.
Being in Denmark, our users all have +45.
To make sure that I don't mess up another country code I tried using this:
[cb:parse function="first" search="+"][cb_cell][/cb:parse] Not Equal To 0
and the action was
Field cb_cell
prefix +45

But no matter if people have entered +xx or not, it adds +45

I thought the search returned the positition of the search string, and if it was strpos it used, it should start with 0? I've also tried entering 1, that didn't help.
I would love to have more condition documentation in the auto action documentation :-)

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.
Last edit: 8 years 7 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: 49447
  • Thanks: 8467
  • Karma: 1465
8 years 7 months ago #289163 by krileon
There is no parse function called "first". There's "position" though which is what you seam to be trying to do. Example as follows.

[cb:parse function="position" search="+" occurrence="first"][cb_cell][/cb:parse]

I'd probably just use a REGEXP condition as follows.

[cb_cell] Is Not REGEXP /^\+/

That should match if that field doesn't begin with +. However, the problem with what you're doing is you're modifying the stored value. It maybe better to just do this through substitutions in the layout for that field. Example as follows for Profile Value Layout.

[cb:if username!~"/^\+/"]+45 [/cb:if][value]


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.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 7 months ago #289171 by fribse2011
Thanks, I absolutely do not understand the example then:

Very confusing explanation, but I see your way of using it...

I use the phonenumber in AcySMS, and I don't think a display substitution will work there...

I'll test with the regexp.

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.
Attachments:

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 49447
  • Thanks: 8467
  • Karma: 1465
8 years 7 months ago #289184 by krileon
The function in that example is "position" as the example shows. The variables supported by that function are "search" and "occurrence". "search" specifies what you want to find in the value supplied and "occurrence" specifies if you want the first or the last result of the search; it then returns the position of that search string.


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

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

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
8 years 7 months ago - 8 years 7 months ago #289194 by fribse2011
It works perfectly with the regexp, I've used that, and a 'non empty' condition, then it does the job.

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.
Last edit: 8 years 7 months ago by fribse2011.
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum