Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author donmik

    (@atallos)

    You can check it inside the template responsible of display the post. Something like this:

    if (xprofile_get_field_data('XXX', bp_loggedin_user_id() === 'YYY'):
     display post
    else:
     don't display post
    endif;

    Replace “XXX” with the name or ID of your field. Replace “YYY” with the value you want.

    Thread Starter nuovoutente

    (@nuovoutente)

    Hi domnik!
    Where do I paste this code? Is it okay if I paste it in single.php?

    Another question:
    XXX is the new custom field that i’ve created before
    YYY is the value of this custom field, right?
    Example:
    XXX = hobby (category)
    YYY = technology (value)

    So, in “if” code i insert for example a link visible only to those who chose “technology” as value of custom field “hobby”, while in “else” code I post only a text message informing users that the link is not visible to those who do not have these “technology” as value of custom field “hobby”, right?

    I need to make other changes to the code to get what I want?

    Plugin Author donmik

    (@atallos)

    You should do it inside single.php inside the loop of posts.

    XXX is the name or ID of the custom field you want to filter.
    YYY is the value of this custom field you want to filter.

    I don’t know what you want to do. If you want to hide the link of post, you should do this and instead “display post” print the link. But if you want to hide the post, you have to do it in single.php and redirect user to homepage for example if he doesn’t have the value you need… It depends what you need to do.

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

The topic ‘Post/topic restricted for some user with specific field’ is closed to new replies.