Tell us what you are trying to do? Please see this previous support thred = https://toolset.com/forums/topic/allow-users-to-input-a-set-number-of-posts-via-user-form/
Where Christian very kindly gave me a code snippet (please see his first response, and the text "4. The ability to automatically subtract one "credit" each time the User posts a new post with Forms", this is what I am referring to here. The code snippet that I was supplied for that function, I have tried to add to the functions.php file in my child theme, but it is not working (ie after I input a post form for my custom post type, it is not reducing my User Custom Field 'ORC Credits' by an increment of 1, the field value is staying the same as before.
Is there any documentation that you are following?
I am following the code snippet I was supplied in that thread, however I have updated it to work with my Custom Field / Post Form, this is the code I am using in my functions.php file in my child theme:
// automatically subtract 1 from the current user's credits field
// when a new post form is submitted
// https://toolset.com/forums/topic/allow-users-to-input-a-set-number-of-posts-via-user-form/
add_action('cred_save_data', 'tssupp_decrement_credits',10,2);
function tssupp_decrement_credits($post_id, $form_data) {
// edit these values as needed
$slug = 'orc-credits';
$forms = array( 146 );
// do not edit below this line
if ( in_array( $form_data['id'], $forms ) )
{
$user = wp_get_current_user();
$credits = get_user_meta( $user->ID, 'wpcf-' . $slug, true );
if( $credits >= 1 )
{
$credits = $credits-1;
update_user_meta( $user->ID, 'wpcf-' . $slug, $credits );
}
}
}
** orc-credits is the slug for my User Custom Field (ORC Credits), and the form ID of my Post Form for my custom post type (References) is 146 (which is what I have put in the $forms variable.
Is there a similar example that we can see?
I can give you access to the form page if required, but it is not publically accessible (it is only viewable for certain User Roles), so if you want access I can set you up with a login no problem.
What is the link to your site?
hidden link (I would like this link hidden from public view if possible please)
If you need any more information from me please do not hesitate to ask.
Thanks very much for your help,
Keith