when you say 'not return a URL' you mean it won't get me the 'value for the variable'... am I right?
Yes, I meant that we won't get the ID of the distributor who met the criteria. And it will return an empty string.
I am aware this does not fulfill your use case exactly (return null for the fields' values), and as I explained, all my tests were done on the content template "Eyewear Collection - Inventory URL - Legacy editor" with ID 46475.
The solution uses several parts:
- A custom shortcode.
- A view.
- A content template to build the final URL. The content template is versteckter Link
Unfortunately, the content template was reset because the URL I shared(it contained &reset=true)
I added a couple of shortcodes to demonstrate what distributor we have got.
Check this page with the "optician" user versteckter Link
Here a screenshot versteckter Link you will see that all fields are returned except bo-name, which we try to get with the following shortcode:
[types field='organisation-name'][/types]
Maybe the custom field slug has a typo or is different.
This page is rendered using the "Eyewear Collection - Inventory URL - Legacy editor" content template, just for testing. You can check this content template to see how the shortcode is used.
The URL is built using the following content template, only, if a distributor is found versteckter Link
As you can see in the custom code at line 60, we are passing the ID of the distributor to the content template. But if we don't find a distributor the shortcode simply returns an empty string.
Please check the custom shortcode code, I added comments to it to explain each step. You can adapt the custom shortcode code to exactly suit your need. Replace each return of an empty string with the desired outcome.
The provided solution is primarily to explain how you can achieve the expected result with the minimal custom code possible. I am sure you will understand that we are limited in the amount of custom code support we can offer.
Check the content template "Distributor URL" to see how the URL is built. Then check the content template "Eyewear Collection - Inventory URL - Legacy editor" to see how the shortcode is being used.
Then update the code of your "Inventory button" to use the shortcode for the parts of the URL that we need to get from the Distributor.
I hope, you understand, how we built this solution. That's important to let you use it and get inspired for other cases where intermediary posts are involved.