1

I am not a coder but I'd like to do this line of code:

If the logged in user is a member of the Organic group team1

Then show a Link to node/add/team_1_content with 'Text' = create node

Else show nothing.

2 Answers 2

2

Create a block that includes that "Link to node/add/team_1_content with 'Text' = create node" as in your question.

Then use the Rules block visibility module. Here is a quote from its project page:

The Rules block visibility module allows Rules components to be used to control block visibility. This provides Drupal administrators and developers extreme flexibility in controlling when blocks should be displayed on their websites, in addition to the default visibility options provided by Drupal.

The general idea is that if you can do it with Rules, you can use it to control block visibility, so the possibilities are limitless:

  • Need to show a block only for users registered more than a month ago?

  • Perhaps you have a block that must be shown only between 8am-5pm on weekdays?

  • What about displaying or hiding a block based on current weather conditions?

All of this can be done by using Rules block visibility.

With that, and as per the "if you can do it with Rules, you can use it to control block visibility" above, you've reduced your question to making Rules "check if the logged in user is a member of the Organic group team1".

For an illustration of how to use this module, refer to my answer to "How to stop a Views block from displaying to admins, such as user/1?".

6
  • Looks like an easy solution since I am not using panels. I'll work on it now and post the results here. Thanks
    – yogi Moh
    Mar 27, 2016 at 18:50
  • Thank you for considering my suggestion! I look forward to your results ... Mar 27, 2016 at 19:37
  • Great post. Don't know how I've never come across that module. Mar 28, 2016 at 5:12
  • 1
    @NiallMurphy : I too think that this module is a hidden D7 gem ... I only discovered it earlier this year. And it took me a very little time to figure out what it could really be used for (there is no documentation about it, at least not that I know). If you're interested, have a look at these answers for similar use cases (the trick (answer) is always the same/similar of course). Mar 28, 2016 at 9:12
  • I am still working on the main structure. I will implement this when I am done since it looks like an easy solution.
    – yogi Moh
    Apr 1, 2016 at 16:05
1

Another approach is to install og_extras since it will create a block with all the correct links for posting content for a particular group. All you need to then do is also enable the block, so that it is visible. Links will show automatically if user is a member.

To quote from og_extras module page:

Extra functions, blocks, and views for Organic Groups 7.2. In particular, this module adds views and blocks needed by sites that are not using Panels, although it also may be useful to sites that do use Panels. This module is for Organic Groups 7.2. It will not work with Organic Groups 7.1.

You will also need to install eva module. Also make sure organic groups is configured to prepopulate by using entityreference_prepopulate module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.