Hi just wondering if its possible to use [wpv-conditional] on a page like this
`[wpv-conditional if="(current_user_can('edit_posts') eq 1)"]
can edit [cred_form form="workers-add-new-retirement-housing-to-the-database"]
[/wpv-conditional]
[wpv-conditional if="(current_user_can('edit_posts') ne 1)"]
cannot edit [cred_form form="new_entry"]
[/wpv-conditional]`
- attempting to show a different form based on whether user has edit permission or not.
am I doing this wrong?
Hi,
Thank you for contacting us and I'd be happy to assist.
To check for the user's specific capability, you can register a custom shortcode:
add_shortcode('check_current_user_can', 'check_current_user_can_func');
function check_current_user_can_func($atts) {
$user_cap = $atts['cap'];
return current_user_can( $user_cap );
}
Next, please add "check_current_user_can" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.
After that, this custom shortcode can be used to check for a specific capability for example "edit_posts" like this:
[check_current_user_can cap="edit_posts"]
Note: The shortcode will return '1' when true and nothing when false.
And the same shortcode can be used in a conditional statement, like this:
[wpv-conditional if="( '[check_current_user_can cap="edit_posts"]' eq '1' )"]
can edit [cred_form form="workers-add-new-retirement-housing-to-the-database"]
[/wpv-conditional]
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar