Skip to:
Content
Pages
Categories
Search
Top
Bottom

[resolved] How can I give a request membership link to a private group


  • anubhavkushwaha
    Member

    @anubhavkushwaha

    The link seems to require the wpnonce variable to be passed to it. Is there a way to do it through a link in a post or a page?

Viewing 5 replies - 1 through 5 (of 5 total)

  • anubhavkushwaha
    Member

    @anubhavkushwaha

    Update – I tried using the link /groups/group_name/request-membership/ but that is not working


    anubhavkushwaha
    Member

    @anubhavkushwaha

    Would this code work “ to get the registration button for the group?


    anubhavkushwaha
    Member

    @anubhavkushwaha

    earlier post – Ok I am guessing that I need to pass a group object to the bp_get_group_join_button function and not the name of the group. So my next question is – is there a way to get a group object if I know a group name?

    Managed to get it done finally.

    `
    <?php
    global $wpdb;
    $mgroup_name = “mygroupname”;
    $myrows = $wpdb->get_results(“SELECT * FROM wp_bp_groups where slug=’$mgroup_name’;”, OBJECT);
    if (count($myrows)>0) {
    $group1 = $myrows[0];
    $buttondata=bp_get_group_join_button($group1);
    }

    ?>

    var registrationbutton = “”;
    `


    anubhavkushwaha
    Member

    @anubhavkushwaha

    false positive. The button does not seem to work on another page even though it has the right link. I am looking for the related form now :(


    anubhavkushwaha
    Member

    @anubhavkushwaha

    ok – so here is what was missing – there needs to be an ajax call that has to be made when the button is clicked :) that is what actually does the trick

    `
    $j(“div.signupbutton a”).live(‘click’, function() {
    var gid = $j(this).parent().attr(‘id’);
    gid = gid.split(‘-‘);
    gid = gid[1];

    var nonce = $j(this).attr(‘href’);
    nonce = nonce.split(‘?_wpnonce=’);
    nonce = nonce[1].split(‘&’);
    nonce = nonce[0];

    var thelink = $j(this);

    $j.post( ajaxurl, {
    action: ‘joinleave_group’,
    ‘cookie’: encodeURIComponent(document.cookie),
    ‘gid’: gid,
    ‘_wpnonce’: nonce
    },
    function(response)
    {
    var parentdiv = thelink.parent();

    if ( !$j(‘body.directory’).length ) {
    location.href = location.href;
    //do stuff that you want to do on successful request send
    parentdiv.fadeIn(200).html(“Thanks for signing up”);
    }
    else {
    $j(parentdiv).fadeOut(200,
    function() {
    parentdiv.fadeIn(200).html(response);
    }
    );
    }
    });
    return false;
    });
    `

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[resolved] How can I give a request membership link to a private group’ is closed to new replies.
Skip to toolbar