Condition using shortcode

Hello,

I have a shortcode which returns the string Safe or Unsafe, which I’d like to use as a condition.

The Condition string is this: [hps_validate_url url={{dc:acf:post_field field=“hps_rhs_url”}}]

In testing with this URL https://www.rhs.org.uk/plants/9/abeliophyllum-distichum/details the output is the string “Safe”.

I’ve tried making a condition using the output of the shortcode but something isn’t working.

Is this actually valid for pro? According to a post I saw from Kory I think it ought to work.

Any guidance?

Thanks, Bill.

1 Like

Here’s the post from Kory - how does that work below? Should the shortcode return True or False?

Hello @bill_hodgson,

Thanks for writing in!

The example URL is not using the Pro theme. The shortcode should work. You can try using IS or IN. If this does not help, we would love to investigate your site. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.

I will give you access and also share the source code so you can see what it does. It’s a very short function behind the shortcode.

  • I’ve made a test page
  • One button has the output of the shortcode as the button label text
  • The other button has a condition testing the shortcode output

The text string output looks good, but the condition isn’t working so one button remains invisible.
Do whatever you like, but try not to destroy the site :wink:

Hi @bill_hodgson,

I have checked your site and also created a sample shortcode in my local environment and implemented a similar condition, and found the issue you described here. I will report this issue to our issue tracker, so this issue will be queued for investigation by our development team.

Thanks

Thanks - are you able to tell me if this is in the pipeline for a fix? Bill.

Hello Bill,

We have already reported the issue and the issue is in our issue tracker for our development team. There is no ETA at the moment so I would request you, please stay tuned for succeeding theme updates.

Thanks for understanding

I found another similar situation.

  1. Make a shortcode which returns a valid URL
  2. Make a button
  3. Put that shortcode into the URL field of the button
  4. Random things happen in the URL returned

I’m pretty sure this is similar to the above. Please try this for yourselves.

Hi Bill,

I will surely check and add this comment to the issue so our development team will be aware of it too.

Thanks

Any update on this? Bill.

Hi Bill,

Unfortunately, there is no news on this till now.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.