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.

Add custom capability tags

Home Forums Community Forum Add custom capability tags

Tagged: 

This topic contains 12 replies, has 3 voices. Last updated by  Cristián Lávaque 4 years, 2 months ago.

Topic Author Topic
Posted: Wednesday Oct 10th, 2012 at 11:07 am #27994
Core Love
Username: corelove

I am looking for an easy way to add a custom capability tag for my members. Is there a way to create a form that is submitted and a custom capability tag is added to their account? I know this can be done with a paid form easily, but I want to do it with a Free form.

List Of Topic Replies

Viewing 12 replies - 1 through 12 (of 12 total)
Author Replies
Author Replies
Posted: Wednesday Oct 10th, 2012 at 11:08 am #27995
Core Love
Username: corelove

Even just a link that they could click on and s2member would add it to their account would be great.

Posted: Wednesday Oct 10th, 2012 at 8:35 pm #28048
Raam Dev
Username: Raam
Staff Member

Hello,

All of the Pro-Forms, including the Free Registration form (Dashboard -› s2Member® -› PayPal® Pro Forms -› Free Registration Forms) can be configured to add Custom Capabilities to someone’s account.

To upgrade existing members (including free members) and add/remove their Custom Capabilities, you can use the Billing Modification form (Dashboard -› s2Member® -› PayPal® Pro Forms -› Billing Modification Forms). If you want to sell individual Custom Capabilities and have them added to an existing member’s account, you can use the Dashboard -› s2Member® -› PayPal® Pro Forms -› Capability (Buy Now) Forms.

However, if you want to add Custom Capabilities to a Free Member’s account without charging them (i.e., they remain a free member), you’ll need to write your own PHP code for that. This thread explains how that’s done with PHP.

Posted: Thursday Oct 11th, 2012 at 2:57 am #28084
Core Love
Username: corelove

I would like to be able to create a shortcode that would enable me to add or remove a ccap by clicking a link. The shortcode would also contain values to customize the link, the link image or text, width and height of image and description.

I figure this would have to be done in the functions.php file. Would anyone know how to do this? This one feature would enhance S2member in a huge way and enable full customization over the flow of information a website.

  • This reply was modified 4 years, 2 months ago by  Core Love.
Posted: Thursday Oct 11th, 2012 at 7:45 am #28108

This article may help you with that: Knowledge Base » Changing Roles/Capabilities via PHP :)

Posted: Thursday Oct 11th, 2012 at 11:23 am #28139
Core Love
Username: corelove

I am Not looking to change the ccap of all members. I just want a ccap to be added or taken away when a single member clicks on a link. I am not sure how I would use a link with what you have referenced or how I would do this.

  • This reply was modified 4 years, 2 months ago by  Core Love.
Posted: Friday Oct 12th, 2012 at 7:46 am #28215

You’d link to a page with the PHP that adds/removes the ccap for that user. The article explains what PHP to use, you then need to create the script that uses it.

I hope that helps. :)

If you don’t know PHP enough to do that, you may want to get help from a freelancer.

Posted: Friday Oct 12th, 2012 at 10:16 am #28245
Core Love
Username: corelove

add_cap(“access_s2member_ccap_f4t23”);
$user->remove_cap(“access_s2member_ccap_videos”);
header(‘Location: http://www.domain.com/’,TRUE,303);
?>

The redirect is not working on the page that this is posted.

  • This reply was modified 4 years, 2 months ago by  Core Love.
Posted: Saturday Oct 13th, 2012 at 1:01 am #28296

Part of your code seems to be missing, or changed. Could you post the full script you tried, inside HTML code tags? Thanks! :)

Also, did you try the redirection with just the location, without the additional parameters?

Posted: Saturday Oct 13th, 2012 at 3:04 pm #28346
Core Love
Username: corelove
<?php
$user_id = S2MEMBER_CURRENT_USER_ID;
$user = new WP_User($user_id);
$user->add_cap("access_s2member_ccap_f4t23");
$user->remove_cap("access_s2member_ccap_videos");
header('Location: http://www.loveinnerversity.com/);
?>

I have tried it without the additional parameters.

It will add and remove the ccap from the account. I just can’t get it to redirect.

This is posted inside of a wp page. php is enabled which is why the add/remove ccap works. All I need it to do is redirect to the next page.

Posted: Saturday Oct 13th, 2012 at 5:56 pm #28356

Ah, if you’re already in the WP page’s content, the headers have already been sent. So you can’t use header to redirect, you’ll need to use JavaScript.

Posted: Tuesday Oct 16th, 2012 at 11:43 pm #28625
Core Love
Username: corelove

Thank you for the tip, i will check into doing it with javascript code.

Posted: Wednesday Oct 17th, 2012 at 9:45 am #28692

Cool. :)

Viewing 12 replies - 1 through 12 (of 12 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.