We cannot assist custom code debugging.
https://toolset.com/toolset-support-policy/
To craft custom code you need to either have the knowledge to do so or contact a Contractor, for example, which can help with these tasks:
https://toolset.com/contractors/
Here we can only hint, and give suggestions, as Toolset is built with one main purpose in mind:
Avoid custom code.
I understand that sometimes, it's not possible elsehow, but we still can be of limited assistance only, in these cases.
Let me reply to your doubts you expressed above:
1. I get a syntax error, unexpected 'if' (T_IF) in line 6. I am using the Snippets plugin for extra code.
This is due to a missing ";" at the end of your code line:
$cpt_slug = 'job-application' // Edit as required
2. I still see results from other users, when I am logged in as a customer or subscriber.
I am using a standard WP search widget inserted into the footer, so as not to add another layer of confusion.
Can you explain how this issue is related to Toolset?
The only search feature Toolset offers is in Toolset Views Custom Searches.
Those can be enhanced using Relevannsi, but only what relates to "where to search". Not "what is displayed".
In Views, or WordPress Archives created with Views, this fully depends on:
- conditionals in HTML
- Query settings
- Access Rules
- Post settings
Note that for example in a View, you may see posts that are private, if not excluded or specified otherwise in the View.
Or, you may see posts the user should not read as set in Toolset Access.
Toolset Access rules, for example, do not affect Views lists.
But, as far I understand this, you use neither Views nor archives styled with Views, but Relevannsi and inbuilt WordPress Core features.
What you see would not depend on where the Post or Fields are created (Toolset, probably), but on the plugins, you use to build the search.
The code as well seems not related to Toolset.
I suggest to contact the Support of the related plugin.