latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Auto Populate Custom Capability With Username

Home Forums Community Forum Auto Populate Custom Capability With Username

This topic contains 1 reply, has 1 voice. Last updated by  Shayne Letford 3 years, 4 months ago.

Topic Author Topic
Posted: Saturday Aug 31st, 2013 at 6:04 am #58915

Hello,

Is there a way to automatically populate the user custom capability field with the username at Registration?

I am currently offering free registration for my site. However, since each user will have access to their own page (much like the Client Portal Video here: http://www.s2member.com/videos/716DC24E7E347DC2), I need their custom capability to equal their username instead of everyone having the same capability. Since it’s not feasible to do this manually every time someone registers, I would like this to happen automatically during the registration process. Is this possible?

I poured though the forum posts and the closest thing that I could find was the following code:

add_action("gform_user_registered", "add_custom_user_meta", 10, 3);  

function add_custom_user_meta($user_id, $config, $entry) {  
    wp_set_current_user( $user_id );
    $user = wp_get_current_user(); 
    $user->add_cap("access_s2member_ccap_music"); 
} 

This would work great if I was using Gravity Forms for registration and needed the custom capability for all of the new registrations to be “music”, but unfortunately that is not exactly what I want. My PHP is not so great (it’s borderline pitiful), so the many attempts to alter this code to suit my needs have failed :( I’m not even sure if this is the right direction. Can anyone please help?

Thanks

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Thursday Sep 5th, 2013 at 4:01 pm #59163

Hello…Would anyone anyone be able to steer me in the right direction on this?

Viewing 1 replies (of 1 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.