Community Support Forums — WordPress® ( Users Helping Users ) — 2011-11-15T22:43:14-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=15857 2011-11-15T22:43:14-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=53147#p53147 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]> @peeld
Donation received. Thank you VERY much.
~ You are very welcome :-)

Please let us know if you need anything.

Statistics: Posted by Jason Caldwell — November 15th, 2011, 10:43 pm


]]>
2011-11-15T21:49:20-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=53141#p53141 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]>
I'm using that 'donate' button right now to donate as a thanks - much rather give that $$ to the software developer, glad I didn't go with the custom coding thing after all ;)

Statistics: Posted by peeld — November 15th, 2011, 9:49 pm


]]>
2011-11-15T17:22:33-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=53114#p53114 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]> Thanks for the heads up on this thread.

In more recent versions of BuddyPress and s2Member, the template_redirect Hook is too late in the processing routines to work as expected. Try changing all of your add_action calls to "wp" instead.

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
( these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins )
Code:
<?php
add_action 
("wp", "my_custom_capabilities");
function my_custom_capabilities ()
    {
        if (bp_is_groups_component () && bp_current_item () == 'goal-setting-and-mental-management' && !current_user_can ('access_s2member_ccap_goalsettingworkingfall2011') && !current_user_can ('access_s2member_ccap_goalsettingauditingfall2011'))
            {
                header ('Location: ' . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit;
            }
        else if (bp_is_groups_component () && bp_current_item () == 'runningcontacts-i' && !current_user_can ("access_s2member_ccap_runningcontactsiworkingfall2011") && !current_user_can ('access_s2member_ccap_runningcontactsiauditingfall2011'))
            {
                header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }
        else if (bp_is_groups_component () && bp_current_item () == 'agility-foundation' && !current_user_can ("access_s2member_ccap_foundationclassworkingfall2011") && !current_user_can ('access_s2member_ccap_foundationclassauditingfall2011'))
            {
                header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }
        else if (bp_is_groups_component () && bp_current_item () == 'hooligans' && !current_user_can ("access_s2member_ccap_hooligan"))
            {
                header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }
    }
?>

Statistics: Posted by Jason Caldwell — November 15th, 2011, 5:22 pm


]]>
2011-11-15T14:12:08-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=53068#p53068 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]>

Statistics: Posted by peeld — November 15th, 2011, 2:12 pm


]]>
2011-11-15T13:35:18-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=53051#p53051 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]>

Daisy

Statistics: Posted by peeld — November 15th, 2011, 1:35 pm


]]>
2011-11-15T01:58:43-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=53004#p53004 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]>
If I were hiring someone, I'd look at the feedback they've received for past jobs (elance.com has this integrated, jobs.wordpress.net doesn't). I'd also make a full backup of the site before giving him access. I'd change the login info after he finishes the job. I'd compare the files with the ones in the backup to see what he did.

Another solution would be to have him install the stuff in his own server (WordPress, BuddyPress and s2Member, same versions you have), code the customization you need and then just deliver to you the file with the hack so you just upload it. Make sure you review the code to check that it doesn't do anything weird. I'd probably prefer this approach.

I hope that helps. :)

Statistics: Posted by Cristián Lávaque — November 15th, 2011, 1:58 am


]]>
2011-11-14T01:42:40-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=52948#p52948 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]>
I got several responses to my request, are most of these legit, how much do I need to worry about filtering out people who might potentially take advantage of access to my back end?

Statistics: Posted by peeld — November 14th, 2011, 1:42 am


]]>
2011-11-12T03:44:45-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=52867#p52867 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]>

Statistics: Posted by Cristián Lávaque — November 12th, 2011, 3:44 am


]]>
2011-11-12T01:08:25-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=52836#p52836 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]>

Statistics: Posted by peeld — November 12th, 2011, 1:08 am


]]>
2011-11-12T00:24:14-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=52833#p52833 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working - ]]>
I'm not very familiar with BuddyPress, and custom capability protection of groups is not something that s2Member does by default, free or Pro, that's why you needed that hack in functions.php, even if it wasn't very complicated. I really don't know why it won't work now although it used to before. It's not that I help you less because I thought you weren't a Pro user.

I suggest that you post a job for a freelance developer to make this work for you again. You can try here: viewforum.php?f=37

I really hope that helps. :)

Statistics: Posted by Cristián Lávaque — November 12th, 2011, 12:24 am


]]>
2011-11-10T15:19:41-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=52715#p52715 <![CDATA[Re: Buddypress Custom Capabilities for Groups not working -]]>
I *am* a Pro purchaser, not a freebie user, and I'm still willing to pay MORE. Hopefully that gives an idea of the urgency here...

Statistics: Posted by peeld — November 10th, 2011, 3:19 pm


]]>
2011-11-09T20:29:00-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15857&p=52693#p52693 <![CDATA[Buddypress Custom Capabilities for Groups not working - HELP]]>
I upgraded to BP 1.5+, and now, my custom capability code, placed in my theme's functions.php file, is no longer working. I am currently using URI protection to at least keep general users who aren't logged in from seeing groups they haven't paid for access to, but those who have paid access can still see any group that's Private. The way it USED to work was just as it should; if the user had the correct ccap, they could view the group by clicking on it in the menu, but if they didn't they got bumped back to the S2Member Options Page.

The code I used that was working til the BP 1.5+ upgrade is shown below:

Code:
/** s2member code */

add_action ("template_redirect", "my_custom_capabilities", 1);

function my_custom_capabilities ()

   {

   if (bp_is_groups_component() && bp_current_item() == 'goal-setting-and-mental-management' && !current_user_can('access_s2member_ccap_goalsettingworkingfall2011') && !current_user_can('access_s2member_ccap_goalsettingauditingfall2011')) {
    header('Location: ' . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
    exit;
}
    else if (bp_is_groups_component() && bp_current_item() == 'runningcontacts-i' && !current_user_can("access_s2member_ccap_runningcontactsiworkingfall2011") && !current_user_can('access_s2member_ccap_runningcontactsiauditingfall2011'))
         {
                header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                exit ();
            }

   else if ( bp_is_groups_component() && bp_current_item() == 'agility-foundation' && !current_user_can("access_s2member_ccap_foundationclassworkingfall2011") && !current_user_can('access_s2member_ccap_foundationclassauditingfall2011'))
     {
      header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
      exit ();
       }

   else if ( bp_is_groups_component() && bp_current_item() == 'hooligans' &&!current_user_can("access_s2member_ccap_hooligan"))
    {
      header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
      exit ();
   }
   
   }
/** end s2member code */

**The Above Code does NOT currently work**

The code Christian recommended is below but also doesn't work:

Code:
    /** s2member code */
    add_action ("template_redirect", "my_custom_capabilities", 1);
    function my_custom_capabilities ()
       {
       if (bp_is_groups_component() && bp_is_single_item() && bp_current_item() == 'goal-setting-and-mental-management' && !current_user_can('access_s2member_ccap_goalsettingworkingfall2011') && !current_user_can('access_s2member_ccap_goalsettingauditingfall2011')) {
        header('Location: ' . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
        exit;
    }

        else if (bp_is_groups_component() && bp_is_single_item() && bp_current_item() == 'runningcontacts-i' && !current_user_can("access_s2member_ccap_runningcontactsiworkingfall2011") && !current_user_can('access_s2member_ccap_runningcontactsiauditingfall2011'))
             {
                    header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                    exit ();
                }

       else if ( bp_is_groups_component() && bp_is_single_item() && bp_current_item() == 'agility-foundation' && !current_user_can("access_s2member_ccap_foundationclassworkingfall2011") && !current_user_can('access_s2member_ccap_foundationclassauditingfall2011'))
         {
          header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
          exit ();
           }

       else if ( bp_is_groups_component() && bp_is_single_item() && bp_current_item() == 'hooligans' &&
    !current_user_can("access_s2member_ccap_hooligan"))
        {
          header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
          exit ();
       }

       }
    /** end s2member code */


Christian also rewrote the code to clean it up, and THAT didn't work either:

Code:
add_action('template_redirect', 'my_custom_capabilities', 1);
function my_custom_capabilities()
{
    if ((bp_is_groups_component() && bp_is_single_item()) && (
        (bp_current_item() == 'goal-setting-and-mental-management' && !current_user_can('access_s2member_ccap_goalsettingworkingfall2011') && !current_user_can('access_s2member_ccap_goalsettingauditingfall2011')) ||
        (bp_current_item() == 'runningcontacts-i' && !current_user_can('access_s2member_ccap_runningcontactsiworkingfall2011') && !current_user_can('access_s2member_ccap_runningcontactsiauditingfall2011')) ||
        (bp_current_item() == 'agility-foundation' && !current_user_can('access_s2member_ccap_foundationclassworkingfall2011') && !current_user_can('access_s2member_ccap_foundationclassauditingfall2011')) ||
        (bp_current_item() == 'hooligans' && !current_user_can('access_s2member_ccap_hooligan'))
    ))
    {
        header('Location: ' . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
        exit;
    }
}


I would LOVE any help anybody can provide. To recap, I HAD Buddypress groups protected as custom capabilities, and it was AWESOME, perfect for my needs. As of the BP 1.5+, it no longer works, although URI protection DOES. I have confirmed with the Buddypress people that the functions used in the code are still valid functions and that their use hasn't changed. I've also posted in the Buddypress forums but nobody has answered :(

**Thanks**

Daisy

Statistics: Posted by peeld — November 9th, 2011, 8:29 pm


]]>