We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

get current users Gender/ get Sex in plugins ( for example in user search) | Forum

Marina Bircher
Marina Bircher Apr 6 '15
How can I get the current logged in Users Gender in a Plugin?

I wanted to get the current users sex in this file, in quickSearch() function:

\ow_plugins\usearch\controllers\ajax.php


Isnt it saved somewhere in the Sessions? I also have to get the "Looking for" information. 


How can I manage this? 


In that file, there is this call:

$userId= (int) $_POST['userId'];

$name = BOL_UserService::getInstance()->getDisplayName($userId);


How can I manage this? 
Maybe I could get the gender and looking for like that? but wherefrom do I know the current Users Id? and how to get the gender id (1:male;2:female) from the ow_skadate_account_type_to_gender Table?


Thx for your support!

The Forum post is edited by Marina Bircher Apr 6 '15
Marina Bircher
Marina Bircher Apr 6 '15
OK I managed half of it ^^ 

I wrote this to the ajax.php and wrote a new function getUserSex(); in ow_system_plugins\base\bol\user_service.php 

ajax.php:

$userId = (int) $_POST['userId'];
$sex = BOL_UserService::getInstance()->getUserSex($userId);
if($sex == "8cc28eaddb382d7c6a94aeea9ec029fb"){
$data['sex'] =2;
}else{
$data['sex'] = 1;
}user_service.php:

public function getUserSex( $userId )
{
$user = $this->findUserById($userId);

return ( $user === null ? null : $user->getAccountType() );
}


Now I got the Gender of the current User! super! 


now the difficult part: How to get the "looking for" Information from the DB?


I'm searching it, maybe one of you know the answer, dont be shy just write :)




Marina Bircher
Marina Bircher Apr 6 '15
Soooo people, there is a muuuch easier way:


we have to do it over the QuestionService:

$questionData = BOL_QuestionService::getInstance()->getQuestionData(array( OW::getUser()->getId() ), array('match_sex','sex'));


now get the attributes:


$sex = $questionData[OW::getUser()->getId()]['sex'];

$match_sex = $questionData[OW::getUser()->getId()]['match_sex'];



and finish! 


Thanks for your help ;P

The Forum post is edited by Marina Bircher Apr 6 '15
Guna
Guna Apr 7 '15
Thanks Marina for this useful information
omer
omer Sep 21 '17
usearch plugin not seeking 1.8.4
is it removed?
Abu Road Escort
Abu Road Escort Jul 5 '22
> | Partapur Escorts | < | > | Patan Escorts | < | > | Peepli Escorts | < | > | Phagi Escorts | < | > | Phalodi Escorts | < | > | Phulera Escorts | < | > | Pilani Escorts | < | > | Pilibanga Escorts | < | > | Pindwara Escorts | < | > | Piparcity Escorts | < | > | Pirawa Escorts | < | > | Pokaran escorts | < | > | Pokhran Escorts | < | > | Pugal Escorts | < | > | Pushkar Escorts | < | > | Raipur Escorts | < | > | Raisinghnagar Escorts | < | > | Rajakhera Escorts | < | > | Rajaldesar Escorts | < | > | Rajgarh Escorts | < | > | Rajsamand Escorts | < | > | Ramganj Mandi Escorts | < | > | Ramgarh Escorts | < | > | Rani Escorts | < | > | Raniwara Escorts | < | > | Ratangarh Escorts | < | > | Ratannagar Escorts | < | > | Rawatbhata Escorts | < | > | Rawatsar Escorts | < | > | Rawla Mandi Escorts | < | > | Reengus Escorts | < | > | Reni Escorts | < | > | Renwal Escorts | < | > | Reodar Escorts | < | > | Rishabhdeo Escorts | < | > | Rudawal Escorts | < | > | Rupbas Escorts | < | > | Sadri Escorts | < | > | Sadulshahar Escorts | < | > | Sagwara Escorts | < | > | Sainthal Escorts | < | > | Salumbar Escorts | < | > | Sambhar Lake Escorts | < | > | Samraniya Escorts | < | > | Sanchore Escorts | < | > | Sanganer Escorts | < | > | Sangaria Escorts | < | > | Sangod Escorts | < | > | Sardarshahar Escorts | < | > | Sarmathura Escorts | < | > | Sarthala Escorts | < | > | Sarwar Escorts | < | > | Satalkheri Escorts | < | > | Sawai Madhopur Escorts | < | > | Shahpura Escorts | < | > | Shekhawati Escorts | < | > | Sheoganj Escorts | < | > | Shri Mahaveer Ji Escorts | < | > | Sidhmukh Escorts | < | > | Sikar Escorts | < | > | Simalwara Escorts | < | > | Singhana Escorts | < | > | Sirohi Escorts | < | > | Siwana Escorts | < | > | Sogariya Escorts | < | > | Sojat Road Escorts | < | > | Sri Ganganagar Escorts | < | > | Sri Madhopur Escorts | < | > | Sujangarh Escorts | < | > | Suket Escorts | < | > | Sumerpur Escorts | < | > | Sundelao Escorts | < | > | Sunel Escorts | < | > | Surajgarh Escorts | < | > | Suratgarh Escorts | < | > | Surena Escorts | < | > | Takhatgarh Escorts | < | > | Tankarda Escorts | < | > | Taranagar Escorts | < | > | Tibbi Escorts | < | > | Tijara Escorts | < | > | Todabhim Escorts | < | > | Todaraisingh Escorts | < | > | Todra Escorts | < | > | Tonk Escorts | < | > | Uchain Escorts | < | > | Udaipur Escorts | < | > | Udaipurwati Escorts | < | > | Udpura Escorts | < | > | Uniara Escorts | < | > | Vanasthali Escorts | < | > | Vidyavihar Escorts | < | > | Vijainagar Escorts | < | > | Virana Escorts | < | > | Viratnagar Escorts | < | > |