now, to use above shortcode with [wpv-conditional] shortcode - you need to register the "check_authorize_user" shortcode at:
=> Toolset => Settings => Frontend content tab => Third-party shortcode arguments section
now, you can use above shortcode as:
[wpv-conditional if="( '[check_authorize_user]' eq '1')"]
user ID found in repeating field with post meta
[/wpv-conditional]
[wpv-conditional if="( '[check_authorize_user]' eq '0')"]
user ID NOT found in repeating field with post meta
[/wpv-conditional]
Great, this has worked - I just have one loose end to solve, as follows...
Currently the Authorised Resellers are selected through two CRED forms (New Vessel and Edit Vessel)
I have found that if I use the Edit Vessel form to un-select a Reseller, the field value is not removed from the Vessel CPT.
Can you advise on how to make this possible?
The current code is as below...
// New Vessel CRED Form - Save Authorised Resellers to CPT
add_action('cred_save_data', 'new_vessel_save_authorised_reseller',10,2);
function new_vessel_save_authorised_reseller($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==193)
{
$vals= isset( $_POST["vessel-authorised-reseller"] ) ? $_POST["vessel-authorised-reseller"] : array();
foreach($vals as $val) {
add_post_meta($post_id, 'wpcf-vessel-authorised-reseller', $val, false);
}
}
}
// Edit Vessel CRED Form - Save Authorised Resellers to CPT
add_action('cred_save_data', 'edit_vessel_save_authorised_reseller',10,2);
function edit_vessel_save_authorised_reseller($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==208)
{
$vals= isset( $_POST["vessel-authorised-reseller"] ) ? $_POST["vessel-authorised-reseller"] : array();
foreach($vals as $val) {
add_post_meta($post_id, 'wpcf-vessel-authorised-reseller', $val, false);
}
}
}
// Edit Vessel CRED Form - Save Authorised Resellers to CPT
add_action('cred_save_data', 'edit_vessel_save_authorised_reseller',10,2);
function edit_vessel_save_authorised_reseller($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==208){
delete_post_meta($post_id,"wpcf-vessel-authorised-reseller");
$vals= isset( $_POST["vessel-authorised-reseller"] ) ? $_POST["vessel-authorised-reseller"] : array();
foreach($vals as $val) {
add_post_meta($post_id, 'wpcf-vessel-authorised-reseller', $val, false);
}
}
}
I've added following line to above code that should delete all post meta related post meta key "wpcf-vessel-authorised-reseller" to post ID.