Membership Level Restrictions

This topic contains 10 replies, has 3 voices, and was last updated by  Stiofan O’Connor 9 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #27092

    Ian Butler
    Buyer
    Post count: 59

    Hi,

    I’m using GeoDirectory in conjunction with S2Members and BuddyPress.

    I use S2Members to handle all membership sign-ups and would like to conditionally display content based on membership level.

    I need to restrict BuddyPress Members from being able to upload Places/Events and instead have this for business owners only.

    So for example the GD > Loginbox:My Dashboard widget should only display for Level 1 members and not Level 2.

    Can you please advise on which template I would need to put the conditional in and how to futureproof this from any updates.

    Thanks in advance

    #27094

    Guust
    Moderator
    Post count: 29970

    Have a look at s2member > restriction options > URI restrictions

    So you would put /add-listing/ in the field for business owners (whatever level they are in your system).

    That will stop members from adding listings, but will not remove from the dashboard widget.
    One way that can be solved is to only use the buddypress login widget, and add the GD dashboard widget to protected page for business owners only.

    #27096

    Ian Butler
    Buyer
    Post count: 59

    Thanks Guust,

    I can add page level restrictions just fine but need to apply some widget logic.

    For example in geodir-location.php i can wrap the right sidebar hook in this code

    if (current_user_is(‘s2member_level4’)) {
    ###### SIDEBAR ######
    do_action(‘geodir_location_sidebar_right’); }

    That of course will remove the entire right sidebar unless the logged in member is Level 4.

    What I’m trying to do is conditionally display just the dashboard widget, not the entire sidebar.

    Is there a file where I can add my code to achieve this?

    #27098

    Guust
    Moderator
    Post count: 29970

    I’ll get Stiofan to look at your question.

    #27100

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Would you not be better adding the restriction on the actual add listing page?

    Stiofan

    #27104

    Ian Butler
    Buyer
    Post count: 59

    That is an option and it would stop certain users adding listings, however I’d rather not give the impression that it’s possible to add listings.

    This might be annoying for the user.

    I would much prefer to display the widget conditionally if this is possible.

    #27109

    Ian Butler
    Buyer
    Post count: 59

    I suppose I could remove the widget completely from the BuddyPress pages and create a set of similar pages for business owners with the widget included, and make these restricted…. Just seems a cumbersome approach.

    Let me know if you can think of a way I can avoid doing this.

    Thanks again.

    #27113

    Ian Butler
    Buyer
    Post count: 59

    Okay on line 359 of geodirectory_widgets.php I have replaced with:

    if (current_user_is(‘s2member_level1’)) { register_widget(‘geodir_loginwidget’); }

    This works and now only shows the widget conditionally.

    Can you foresee any problems with doing this?

    Thanks

    #27125

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    If it were me i would simply copy the widget code into your child theme functions and rename it to your own, then add the conditional call around that, this will mean it won’t be overwritten on updates.

    Thanks,

    Stiofan

    #27129

    Ian Butler
    Buyer
    Post count: 59

    That’s a far cleaner solution – thanks for your help!

    #27132

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Your welcome 🙂

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket