Forum

Forum - DatingScript

Online dating software

You are not logged in.

#1 2015-09-13 17:17:42

jackal
Member

IF/ELSE Statements & more

///////// Note: ////////

jackal wrote:

No sure how correct are the below codes (all codes were grab from the forum and some from the Vlad team).

/////// IF Session User Group Code ////////

<? if (session::item('group_id') == 1): ?>               
Your Text for Paid users
<? elseif  (session::item('group_id') == 2): ?>  
Your Text for Paid users
<? endif; ?>

/////// IF Multi Session User Groups Code ////////

<? if (in_array(session::item('group_id'), array(4,5))): ?> 
Session Groups 4 & 5
<? endif; ?>

/////// IF Member Group Code ////////

<? if ( $user['group_id'] == 5 ): // this is my group id admin ?>              
<b>Admin Member</b>
<? elseif  ( $user['group_id'] == 2 ): // this is my group id paid ?>   
<b>Paid Member</b>
<? elseif  ( $user['group_id'] == 3 ): // this is my group id free ?> 
<b>Free Member</b>
<? endif; ?>

/////// IF Session Members by User Type ////////

<? if (session::item('type_id') == 1): ?>               
Your Text for members in User Type 1
<? elseif  (session::item('type_id') == 2): ?>  
Your Text for members in User Type 2
<? endif; ?>

/////// IF Members by User Type ////////

<? if ( $user['type_id'] == 1 ):  ?>              
User Type 1
<? elseif  ( $user['type_id'] == 2 ): ?>   
User Type 2
<? elseif  ( $user['type_id'] == 3 ): ?> 
User Type 3
<? endif; ?>

/////// If session member is on plan id 1///////

<? if ( session::item('plan_id', 'subscription') == 1 ): ?>
Members on Plan 1
<? elseif ( session::item('plan_id', 'subscription') == 2 ): ?>
Members on Plan 2
<? endif; ?>

/////// Display session user-type ////////

<?=session::item('type_name')?>

/////// Display session user-group ////////

<?=session::item('group_name')?>

/////// Display user-group ////////

<?=$user['type_name']?>

/////// Display user-group ////////

<?=$user['group_name']?>

/////// IF Gender Type & User Group Code ////////

<? if (session::item('data_gender') == 1 & session::item('group_id') == 2): ?> 
IF you gender is X & are a paid member
<? endif; ?>

/////// IF Session Member is Featured ////////

<? if (session::item('featured') == 1): ?>               
Member is Featured
<? elseif  (session::item('featured') == 0): ?>  
Member is Not Featured
<? endif; ?>

/////// IF Member is Featured ////////

<? if ( $user['featured'] == 1 ): ?>              
Member is Featured
<? elseif  ( $user['featured'] == 0 ): ?> 
Member is Not Featured
<? endif; ?>

/////// IF Gender Type ////////

<? if ( key($data_gender) == 1 ): ?> 
 // this is a man
<? else: ?>
 // this is a woman
<? endif; ?>

/////////IF Photo is not approved ////////

<? if (session::item('picture_active') != 1): ?>  
If photo is not approved
<? endif; ?>

///////// IF Photo is approved ////////

<? if (session::item('picture_active') == 1): ?> 
If photo is approved
<? endif; ?>

///////// IF Show Default Member photo ////////

<? if ( session::item('picture_id') ): ?>
Member picture code goes here
<? else: ?>
if no default photo has been added
<? endif; ?>

///////// Display Message on Profile Page Only  ////////

<? if ( uri::segment(1) == 'profile' ): ?>
  profile page
<? endif; ?>

///////// Display Message on Search Result Page ////////

<? if  ( uri::segment(1) . '/' . uri::segment(2) == 'users/results'  ): ?>
search result page
<? endif; ?>

///////// IF Language type ////////

<? if ( session::item('language') == 'english' ): ?>
  <a href="english_uri">english link</a>
<? elseif ( session::item('language') == 'spanish' ): ?>
  <a href="spanish_uri">spanish link</a>
<? endif; ?>

///////// IF Profile Field is Filled ////////

<? if ($user['data_my_keyword_field'] == true): ?>
If profile field is filled in
<? else: ?>
If profile field is empty
<? endif; ?>

///////// IF User is loggin ////////

<? if ( session::item('user_id') ): ?>
 // user is logged in
<? else: ?>
 // user is not logged in
<? endif; ?>

////////// Displays Session Username /////////

<?=session::item('username')?>

////////// Displays User's ID /////////

<?=$user['user_id']?>

////////// Displays User Total Credits /////////

<?=session::item('total_credits')?>

////////// Displays Join User Date & Time /////////

<?='reg. ' . date_helper::formatDate($user['join_date'], 'stamp')?>

////////// Displays User Join Date  /////////

<?='reg. ' . date_helper::formatDate($user['join_date'], 'stamp')?>

////////// Displays User Last Vist Date & Time   /////////

<?='reg. ' . date_helper::formatDate($user['visit_date'], 'stamp')?>

///////// Display User State ////////

<?=current(session::item('data_location_state'))?>

///////// Display Featured Members ////////

<?=users_helper::getUsers(array('join_columns' => array('`u`.`featured`=1', '`u`.`picture_id`!=0', '`u`.`picture_active`=1',), 'limit' => 12, 'order' => 'rand()', 'profile_info' => true))?>

///////// Display members by state (10 = the State ID Number) ///////////

<?=users_helper::getUsers(array('join_columns' => array('`u`.`picture_id`!=0', '`u`.`picture_active`=1', '`u`.`group_id`=7', '`p`.`data_location_state`=10'), 'limit' => 22, 'type_id' => 1))?>

//////// Display Latest Visitors //////

<?=users_helper::getUsers(array('join_columns' => array('`u`.`picture_id`!=0', '`u`.`picture_active`=1',), 'limit' => 12, 'order' => '`u`.`visit_date` desc', 'profile_info' => true))?>

//////// Display Latest Pictures //////

<? loader::helper('pictures/pictures'); ?>
<?=pictures_helper::getPictures(array('join_columns' => array("`p`.`adult`=0", "`p`.`password` is null"), 'limit' => 10, 'order' => '`p`.`post_date` desc', 'albums' => true));?>

//////// Display Users from the same state //////

<? if ( is_array(session::item('data_location')) && session::item('data_location') && is_array(session::item('data_location_state')) && session::item('data_location_state') ): ?>
	<?=users_helper::getUsers(array('join_columns' => array('`u`.`picture_id`!=0', '`u`.`picture_active`=1', '`p`.`data_location`=' . key(session::item('data_location')), '`p`.`data_location_state`=' . key(session::item('data_location_state'))), 'limit' => 10, 'profile_info' => true, 'type_id' => 1))?>
<? endif; ?>

//////// Display Users from the opposite gender //////

<? if ( is_array(session::item('data_gender')) && session::item('data_gender') && key(session::item('data_gender')) == 1 ): // if user is a man, show women ?>
	<?=users_helper::getUsers(array('join_columns' => array('`u`.`picture_id`!=0', '`u`.`picture_active`=1', '`p`.`data_gender`=2'), 'limit' => 10, 'profile_info' => true, 'type_id' => 1))?>
<? elseif ( is_array(session::item('data_gender')) && session::item('data_gender') && key(session::item('data_gender')) == 2 ): // if user is a woman, show men ?>
	<?=users_helper::getUsers(array('join_columns' => array('`u`.`picture_id`!=0', '`u`.`picture_active`=1', '`p`.`data_gender`=1'), 'limit' => 10, 'profile_info' => true, 'type_id' => 1))?>
<? else: // not logged in or user didn't fill in gender so show all users ?>
	<?=users_helper::getUsers(array('join_columns' => array('`u`.`picture_id`!=0', '`u`.`picture_active`=1'), 'limit' => 10, 'profile_info' => true))?>
<? endif; ?>

//////// Display Only Men or Only Women //////

<?=users_helper::getUsers(array('join_columns' => array('`u`.`picture_id`!=0', '`u`.`picture_active`=1', '`p`.`data_gender`=1'), 'limit' => 10, 'profile_info' => true, 'type_id' => 1))?> // men
<?=users_helper::getUsers(array('join_columns' => array('`u`.`picture_id`!=0', '`u`.`picture_active`=1', '`p`.`data_gender`=2'), 'limit' => 10, 'profile_info' => true, 'type_id' => 1))?> // women

//////// Display Chat Now if member is online (cometchat require) ////////

<? if ( users_helper::isLoggedin() && $user['user_id'] != session::item('user_id') ): ?>
	<? if ( $user['online'] ): ?>
        <a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith('<?=$user['user_id']?>');" title="Chat with me">Chat NOW</a>
	<? elseif ( $user['away'] ): ?>
	<a href="javascript:void(0)" onclick="javascript:jqcc.cometchat.chatWith('<?=$user['user_id']?>');" title="Chat with me">Chat NOW</a>
	<? endif; ?>
<? endif; ?>

//////// Create an of advanced url ////////

http://www.domain.com/index.php/users?do_search=1&tab=advanced&data_job_1[]=1

//////// Display Profile field checkbox selection////////

<?=implode(', ', $user['data_cars'])?>

/////// Classifieds search link for country 1 (United State)////////

https://www.mydomain.com/index.php/classifieds?do_search=1&data_location[country]=1

/////// Classifieds search link for session user country////////

https://www.mydomain.com/index.php/classifieds?do_search=1&data_location[country]=<?=key(session::item('data_location_country'))?>

//////// If you want to see what other values are stored in user's session ////////

<? session::toString(); ?>

Last edited by jackal (2018-05-25 10:15:29)

Offline

#2 2015-09-15 12:21:09

gugu
Member

Re: IF/ELSE Statements & more

Thanks for sharing ...

Offline

#3 2015-11-09 16:33:56

orange_slice
Member

Re: IF/ELSE Statements & more

Very useful list.
Thank you very much for sharing.

Offline

#4 2015-11-28 11:10:30

JeffBlack
Member

Re: IF/ELSE Statements & more

This is nice. Very useful!
Thanks for sharing.

Offline

#5 2017-03-10 17:10:23

pzlpieces
Member

Re: IF/ELSE Statements & more

Great resource!

I'm trying to display to a member how many messages they have left to send in a cycle. I've used this code, but I don't see the item I want. I tried a several items that came out (messages_send, message_delay_limit, and a few others), but they don't appear to have any output at all

<? session::toString(); ?>

Offline

#6 2018-03-17 05:44:48

edendom
Member

Re: IF/ELSE Statements & more

Thanks a lot Jackal!

Offline

#7 2018-10-12 11:02:25

rdog
Member

Re: IF/ELSE Statements & more

How do you display the username on profile, not the session name, but the actual person profile username

Offline

#8 2018-10-12 11:49:50

vlad
Support staff

Re: IF/ELSE Statements & more

This will do it

<?=$user['username']?>

Offline

#9 2018-12-06 21:18:22

tigr
Member

Re: IF/ELSE Statements & more

I would like to hide certain content for all users except the owner of that content.

For example only allow the user who received likes on some item, to see the list of users who liked it.

So I think I need something like this:

IF current session = owner of content
>> display this
ELSE
>> display that (i.e. warning message)


What would be the correct syntax for the first line?

Offline

Board footer