One last question,
Is it possible to fill the mail field from urlparam?
Just adding the urlparam="" to cred field?
And another one, do this check the checkbox on all custom posts agent? If someone add his email 2 times (two posts) it will be nice, tu unsubscribe him on both posts...
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Yes - Toolset form's shortcode [cred_field] supports the attribute urlparam :
=> https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
So, yes, you should add the attribute urlparam to the [cred_field] shortcode:
For example:
[cred_field field='email-agent' force_type='field' class='form-control' output='bootstrap' urlparam="url-param-name"]
Where:
Replace the url-param-name with original url param name.
For now, we wrote the code for one post. If you want to have multiple post, you should adjust the code I shared.
So I should use
function to use it for all posts?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Sorry - Can you please elaborate more where exactly you want to use the foreach?
In this snippet:
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
add_action('cred_save_data', 'func_check_sub_email',10,2);
function func_check_sub_email($post_id, $form_data){
// if a specific form
if ($form_data['id']==687){
update_post_meta($post_id, 'wpcf-email-agent','');
$args = array(
'posts_per_page' => -1,
'post_type' => 'agent',
'meta_query' => array(
array(
'key' => 'wpcf-email-agent',
'value' => $_POST['wpcf-email-agent'],
))
);
$query = new WP_Query($args);
if ( $query->have_posts() ) {
if(metadata_exists('post', $query->post->ID, 'wpcf-odhlaseni'))
update_post_meta($query->post->ID, 'wpcf-odhlaseni', 1);
else
add_post_meta($query->post->ID, 'wpcf-odhlaseni', 1);
}else{
update_post_meta($query->post->ID, 'wpcf-odhlaseni', 0);
}
}
}
I need it to look at all DB entries, if there is the mail adress multiple times, to check the chekbox for all. of them.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Yes - you need to use foreach and adjust the code accordingly if needed.