Free registration with ccap

I know how to create a button for a purchase and associate the ccap, but I would like members to register for something free (if they have already purchased something) and associate a ccap with it.

Is there a way to do that?

So the user already has an account, what you want is to add a ccap without requiring a payment, right? I had not thought about that scenario…

You could with a bit of PHP, but there isn’t a way to do it with shortcodes yet. This article may help, until there’s some built-in way to do it… https://s2member.com/kb-article/rolescapabilities-via-php/

You could have a page with the PHP code to give the user the ccap, and have people visit that page when they join. Does that make sense?

:slight_smile:

The idea is that I want to offer that “study group” (from the other thread) to those who want to buy the course (then I use the conditional to display a Buy now button) and those who already bought it (then display something else for them to “register” without buying).

This is currently what I have. The registration for those who already purchased will add a tag to my AC, but I will have to add the ccap manually for now.

I’ll have to look into your suggestion.

If they’re registering, you can add the ccap with the free registration pro-form…

Hum, I would like to avoid forms as they are too big to my liking but maybe it would work. (I wish there was a way to format those forms).

Thanks for the idea.

I just tested that form.
Shouldn’t the form auto-fill when a user is logged in? I don’t want them to have to refill the form with name, username and email AGAIN. It seems excessive for existing members (and can lead to errors too if they mistype). I tested it with a member account (not an admin) and the fields are completely blank.

That’s a registration form, so if they’re logged in, they already are registered.

To modify an existing user giving them the new ccap, you’ll need to do it with PHP in some way.

:slight_smile:

I’ll look if there is a way to use PHP to create a button (avoiding a form).

Well, you could just make it an image button, linked to a page that welcomes them, and on that welcome page have the PHP that gives the user the new capability… E.g.

<?php
$user_id = get_current_user_id();
if (!empty($user_id)) {
  $user = new WP_User($user_id);
  $user->add_cap('access_s2member_ccap_music');
}
?>

I hope that helps. :slight_smile:

Hum yeah… just an extra step. Worth looking into though.

You can do it without that step, but then I’m not sure how you make sure the ccap is given to someone who wants it.

I am using conditionals to display either the BUY NOW button or the “free registration” to the event but …
So far, in the meantime, I might use a popup (only for the ones who do have the right condition) and manually add the ccap inside S2. The tag from the popup will be added to Active Campaign already to trigger the email sequence.

1 Like