For this you will need a custom shortcode to check if the user has already submitted the form. Since this is a CRED form a post is created whenever the form is submitted by that user. So all we need to do is check if the user has a post under that post type.
I've added the code to the functions file ok and after editing the code above to remove the extra ] I have the shortcode working ok (see new screenshot or hidden link)
But it's showing 0 I'm logged in as the admin so should have plenty of posts, do I need to pass the function a user ID?
Also how do i then call this data using the conditional GUI?
Sorry Shane, It's late for me so I'm probably making a simple mistake here, but after following the instruction to add a shortcode and use it in a condition I'm still not sure what I'm doing wrong.
the page is displaying: '<' 0"] COMPLETE1 [/wpv-conditional]
Please see screenshot, I created 4 examples to test the syntax and have one showing, but not how I think it should?
No output.
Here's what I have on the page:
[wpv-conditional if="( '[wpv-current-user info="id"]'] posttype='applic-personal-info' ]' gt '0' )"]
Content here
[/wpv-conditional]
So we're checking to see if the current user has completed any posts with the slug applic-personal-info, then (I'm guessing here) we are asking if the count is greater than 0 to then display "Content Here"
I've added an applic-personal-info post, I'm the author, I'm the logged in user.
I've checked the registered shortcodes [count_my_posts] is registered ok
I've added
// Add Shortcode
function count_my_posts( $atts ) {
Since this is a production site I would rather not interfere with it. However i went ahead and perform some tests and it worked for me.
Try this code
[wpv-conditional if="( '[count_my_posts user_id='[wpv-current-user info="id"]' posttype='post' ]' gt '0' )"]
This is my post count = [count_my_posts user_id='[wpv-current-user info="id"]' posttype='post' ]
[/wpv-conditional]
I forgot to mention that in order for this to work in our wpv-conditional you need to add the shortcode name to our Views 3rd party shortcode arguments .
To do this go to Settings -> Frontend content and add count_my_posts to the 3rd party shortcode arguments.
Shane apologies, I gave you access to the wrong install
I have updated the credentials above.
Whilst the code you provided works, it does not do what I asked for, namely check posts and modify output based on whether they are there or not - can you suggest how I use your solution to do that ?
Also - some posts and comments disappeared from the /admiralbook install I had given you access to - did you have to do a DB restore? it's ok, I just need to know.
What I had in mind is that each user can only complete the questionnaire only once. This means that the code will check if the user created a post of that post type and then not display the questionnaires again.
Is this the intention?
Also I didn't log into the website as it was a production site. All tests were done on my localhost.
Thanks
Shane
The topic ‘[Closed] Output Content based on whether the user has completed CRED forms’ is closed to new replies.