Skip to:
Content
Pages
Categories
Search
Top
Bottom

If Group id = A then Show Ad


  • joestuart
    Participant

    @joestuart

    Hi,
    I am trying to set up a function that looks at the group id and if the logged in user’s group id matches it displays an ad (just a hyperlink and an image). I will probably add the add to a widget (PHP) on a side bar but up for suggestions.

    I am using WP 4.0.1 and buddypress 2.1.1 the site is password protected so I can’t share the link.

    Thank you in advance.
    Joe

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

  • shanebp
    Moderator

    @shanebp

    So this is on a group page?

    $check = groups_is_user_member( bp_loggedin_user_id(), bp_get_group_id() );

    If not a member, $check will = NULL.


    joestuart
    Participant

    @joestuart

    Thanks Shanebp, That is great and exactly what I was after, I have tested it with the following code.

    $check = groups_is_user_member( bp_loggedin_user_id(), bp_get_group_id() );
    if ($check != 0){
     echo "You are a member of the group.";
    } 
    else{
    echo "you are not a member of the group";
    }

    I would like to use it on any page, not just the group page if so could I do something like this?
    $check = groups_is_user_member( bp_loggedin_user_id(), bp_group_id(9) );

    Thanks again.


    shanebp
    Moderator

    @shanebp

    Try it like this:
    $check = groups_is_user_member( bp_loggedin_user_id(), 9 );


    joestuart
    Participant

    @joestuart

    Thank you Shane! Worked perfectly!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘If Group id = A then Show Ad’ is closed to new replies.
Skip to toolbar