Privacy settings

Hello I am working on some privacy settings a php/mysql driven website which allows users to create profiles. I have two options, public and private

I have programed the privacy settings, Now I just need to figure out how to implement it.

The profile is built using functions, e.g

<?
profile_main();
profile_location();
profile_comments();
?>

Is it possible to just add a function at the top to implement that basically doesnt execute the other functions if it matches my if/else?

Create a function which returns either true or false based on your privacy settings.
And put the 3 functions in an if statement to only execute if the privacy settings function returns true.

If that code is appearing in multiple files, you might want to do it this way instead:


if( $private ){
include 'private_setttings.php';

}else{
include 'public_setttings.php';

}

where private_settings contains:


<?php
profile_main();
profile_location();
profile_comments();

That way, when you want to make a site-wide change to private settings you simply edit one file.


<?php
profile_main();
profile_location();
profile_comments();
profile_offers();  // say ...

Whether you win by creating more files like this, and the slight added complexity it brings, will depend on your situation. Just bear it in mind.