Ok. I am going out of my mind here. I think I have tried everything I know to do and still am unable to get this function to work. Here is what i want to do:
I am using s2member for my membership plugin. When I sign a person up using the userregistration plugin, I select s2member_level1 as the role. If I just sign up as is, the following is in the wp_capabilities metakey field:
a:1:{s:15:"s2member_level1";s:1:"1";}
Now, if I add the custom capability manually, I get this in the wp_capabilities metakey field:
a:2:{s:15:"s2member_level1";s:1:"1";s:26:"access_s2member_ccap_test";s:1:"1";}
So, I have tried the following code in the functions.php field:
add_action("gform_user_registered", "add_custom_user_meta", 10, 3);
function add_custom_user_meta($user_id, $config, $entry){
add_user_meta($user_id, 'wp_capabilities', $entry[22]);
}
I have also tried:
add_user_meta($user_id, 'wp_capabilities', 'access_s2member_ccap_test');
add_user_meta($user_id, 'wp_capabilities', "access_s2member_ccap_test");
$custom_cap = 'access_s2member_ccap_test';
add_user_meta($user_id, 'wp_capabilities', $custom_cap);
$user = $user_id;
$user->add_cap("access_s2member_ccap_test");
And I have even tried adding a custom meta in the user registration field and naming it "wp_capabilities". No go on that either.
Every thing I have tried has not resulted in adding the custom capability to the user profile. The user registers just fine, but only at the role level.
Also, how do I only target specific registration forms as using "gform_user_registered_6" does not work.
Thanks for all your help. The form I have been working on is form id 6, website is https://www.freeclassifiedproducts.com/sign-up-for-a-credit-repair-membership?s2-ssl=yes