[Resolved] Conditional Logic Help (with 1 custom USER field and 1 custom post type field)
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hello! I am trying to make a button appear to add more items if the user has NOT gone over their allocated number of X (where X is a custom post type) but if they have hit that amount, a message will appear telling them why the button is gone.
I have a VIEW that outputs the number of X this user has created (and it works great):
[wpv-view name="myexpactivecount" user="[wpv-user field='ID']"]
Each user has a custom USER field where I can enter a number of the total amount of X I want this user to be able to create, this shortcode outputs that number perfectly:
[types usermeta='usertotalexperiences' output='raw' current_user='true']
So I can output something like this:
<small>You are using [wpv-view name="myexpactivecount" user="[wpv-user field='ID']"] out of [types usermeta='usertotalexperiences' output='raw' current_user='true'] of your available Experiences</small><br>
And it looks great!
However, when I use those variables in two conditional logic statement, it does not work 🙁
Below is the conditional logic I have (that does not work), can you tell me why it does not work and help me fix it?
Thank you for contacting us and I'd be happy to assist.
The 3 levels of nesting of shortcodes in the conditional setup that you're using, make it difficult to be recognized by the system.
You can register a custom shortcode, that can process the shortcode for the view ( i.e. [wpv-view name="myexpactivecount" user="[wpv-user field='ID']"] ) and return the output, as a single-level shortcode.
For example:
add_shortcode('myexpactivecount', 'myexpactivecount_fn');
function myexpactivecount_fn() {
// get current user ID
$user_id = do_shortcode("[wpv-user field='ID']");
// generate output from the view's shortcode
$content = do_shortcode("[wpv-view name='myexpactivecount' user='".$user_id."']");
return $content;
}