• MemberCheck not working#

  • danzg Reply #1, 1 year, 6 months ago

    Reply
    I am trying to use MemberCheck (with Revo) but it gives me 'group could not be found', even though there is such a group.

    Anyone?

    Thanks


  • BobRay Reply #2, 1 year, 6 months ago

    Reply
    Try changing the test in the snippet to:

    if ($modx->user->isMember('groupname')) {
    }


    Of course the user will have to log in first.
    Just putting the login snippet on the page and redirecting to the current page is probably a better method.


  • danzg Reply #3, 1 year, 6 months ago

    Reply
    Thanks!


  • Kheos Reply #4, 1 year, 4 months ago

    Reply
    hmm, sounds like I got the exact same issue:
    Membercheck keeps returning
    "The group NewsEditors could not be found..."
    while it does exist. I copy-pasted the name from group in the snippet call and tried to create a group based on the name in the error message(group with that name already exists) so I'm pretty dam sure I typed it correctly.

    I'm using 1.2-beta2 so perhaps that's why I can't retrieve the piece of code you mentioned.
    That or I'm just not sure what you mean by

    Try changing the test in the snippet to:
    if ($modx->user->isMember('groupname')) {
    }


  • BobRay Reply #5, 1 year, 4 months ago

    Reply
    I can't see any packages in Package Manager now, so I can't give you a definitive answer. Basically, the suggestion was to replace the if statement in the snippet that tests for group membership with the line above.

    I'm not sure if that would apply to the current version or not.


  • Kheos Reply #6, 1 year, 4 months ago

    Reply
    that's where you can download it
    http://modxcms.com/extras/download/908/939
    you just have to upload it to the packages folder and in package manager set it to search for local packages. it then will work like a normal package.

    so I guess once I discover this line there are 2 options:
    either it works when I change the code, or it doesn't
    if it still doesn't I guess it has something to do with my group, but what if it does work when I change the code? what can I conclude then? that there is an error in the code? or that I call the snippet incorrectly?


  • BobRay Reply #7, 1 year, 4 months ago

    Reply
    MemberCheck was obviously written for Evolution. It has been updated for Revolution, but only partially. It uses some deprecated functions (e.g. isMemberOfWebGroup()) and it doesn't use xPDO.

    What, exactly are you trying to do? There's probably a much faster way to do it with a custom snippet.


  • Kheos Reply #8, 1 year, 4 months ago

    Reply
    Well, I just want to check if the user is part of the NewsEditors group. If he is, I want a certain chunk displayed and if he's not a different chunk.
    I first tried the Personalize package but that does not check for a group.


  • BobRay Reply #9, 1 year, 4 months ago

    Reply
    Try this:

    [[!EditorCheck]]


    <?php
    
    /* EditorCheck snippet */
    
    $output = $modx->user->isMember('NewsEditors') ? $modx->getChunk('EditorChunk') : $modx->getChunk('nonEditorChunk');
    return $output;


    Or, if you need to send the chunk names and the group name in the snippet:

    [[!MemberCheck? &group='NewsEditors' &yesChunk=`SomeChunk` &noChunk=`SomeOtherChunk`]]


    <?php
    
    /* MemberCheck snippet */
    
    $output = $modx->user->isMember($group) ? $modx->getChunk($yesChunk) : $modx->getChunk($noChunk);
    return $output;





  • David Walker Reply #10, 8 months ago

    Reply
    I've had the same problem. modx.com is rather unclear on MemberCheck's viability for Revo. My advice FWIW, as of now: don't use it. Use Bob's code instead.