This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

mwindey

  • *****
  • 475 posts
If socials logged in then require blablabla else relax :-)
« on: September 07, 2021, 11:03:33 AM »
Special request maybe but I'm looking for the option to only require users who are logged in with socials FB or/and Google to accept the GDPR when placing a listing. The other users are already registered with email in the first page when creating their account and I do not want to ask again and again to agree with the checkboxes...
To only show to logged in people I know
Code: [Select]
<?php if(osc_is_web_user_logged_in() ) { ?>
... content for logged in...
<?php ?>
but would there also be a possibility to recognize logged in people who are logged in with socials?
On my website everyone has to be logged in to be able to do something so it is only recognizing them who are logged in with socials and the ones without.....
Grts
Marc


*

MB Themes

Re: If socials logged in then require blablabla else relax :-)
« Reply #1 on: September 07, 2021, 03:59:56 PM »
@mwindey
You would have to check user record if tc/pp was checked.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 475 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #2 on: September 08, 2021, 12:21:58 PM »
@MB Themes

I did that and works  8) If tc is not checked then it shows all 3 checkboxes and if tc is checked it shows only the newsletter checkbox witch is perfect....
Second is that when also the newsletter is ticked i only want to show some text......
At first when not checked there is
Code: [Select]
<?php  if($tc['value']==0) { ?> ....
All 3 come up

Second part
Code: [Select]
<?php } else if($nw['value']==0) { ?>....
1 comes up showing newletter box

After i need to check if all 3 or at least tc and nw are checked and i'm trying to put that in array like

Code: [Select]
<?php } else if(in_array($tc['value']==1) || ($pp['value']==1) || ($nw['value']==1)) { ?>....continue ...
That does not seem to work  :-[ Any idea how to solve this please?

Marc
« Last Edit: September 09, 2021, 08:31:21 AM by mwindey »

*

mwindey

  • *****
  • 475 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #3 on: September 09, 2021, 11:25:02 AM »
I tried in another way this time....
Added some code to model but result is nothing happens...... Please help :-)
In model i have
Code: [Select]
public function checkGDPR($item_id, $tc, $pp, $nw){
        $this->dao->select('pk_i_id');
        $this->dao->from($this->getTable_item());
        $this->dao->where(array('pk_i_id' => $item_id, 'i_gdpr_tc' => $tc, 'i_gdpr_pp' => $pp, 'i_gdpr_nw' => $nw));
        if($tc==1) {
        return checkbox1;
    }
It doesn't check and i am not able to find out why....
« Last Edit: September 09, 2021, 04:03:38 PM by mwindey »

*

tomi327

  • ***
  • 66 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #4 on: September 09, 2021, 12:40:14 PM »
You need to check GDPR --> user_id ( Table = user ).
« Last Edit: September 09, 2021, 12:47:47 PM by tomi327 »

*

mwindey

  • *****
  • 475 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #5 on: September 09, 2021, 01:55:45 PM »
@ tomi327

I know that in user table the gdpr is used but that is only if a user creates a profile with his email.
If logged in with socials the gdpr doesn't get filled in the user table so i want to make them check the boxes on creating a new listing.
In that case the gdpr from table item gets updated and that is why i am checking on that table and not table user......

Anyway so far without succes  :(

*

tomi327

  • ***
  • 66 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #6 on: September 09, 2021, 04:39:23 PM »
I think you have to check user_id / user table anyway.

If user pp/tc is not 1 --> show item check boxes tc/pp

But I dont think is good idea to use items GDPR checkboxes for it. ;-)

Better way is = if user tp/pp is not 1 --> show user check boxes tc/pp

*

mwindey

  • *****
  • 475 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #7 on: September 10, 2021, 04:13:46 AM »
unfortunately that isn't working either....
I am checking t_user as well as t_item now and still no luck....not even get the data so that if boxes are checked previously they show up checked.
Meanwhile in model....the story continues :-)
Code: [Select]
// GET GDPR DATA
    public function findGdprByUserID($userId)
    {
        $this->dao->select('l.*, i.*');
        $this->dao->from(DB_TABLE_PREFIX.'t_item i, '.DB_TABLE_PREFIX.'t_user l');
        $this->dao->where('l.pk_i_id = i.pk_i_id');
        $array_where = (array('pk_i_id' => $user_id, 'i_gdpr_tc' => $tc, 'i_gdpr_pp' => $pp, 'i_gdpr_nw' => $nw));
        $this->dao->where($array_where);
        $result = $this->dao->get();
            if($tc==1) { {
            return array();
        }
        $items  = $result->result();

        return Item::newInstance()->return($items);
    }

*

tomi327

  • ***
  • 66 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #8 on: September 10, 2021, 05:04:13 AM »
It is wrong at all. ;-)

Use userId and user table only. Do not mix it with itemId and item table. ;-)
Good luck. :-)

*

mwindey

  • *****
  • 475 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #9 on: September 10, 2021, 10:47:06 AM »
Last try  didn't work out so for now i quit trying...... Gonna get me another way to make this work....:-)
This sucks :P
// GET GDPR DATA
        public function findGdprByUserID($user_id){
        $this->dao->select('pk_i_id as $user_id');
        $this->dao->from($this->getTable_user());
        $this->dao->where(array('pk_i_id' => $user_id, 'i_gdpr_tc' => $tc, 'i_gdpr_pp' => $pp, 'i_gdpr_nw' => $nw));
        $this->dao->get($this->getTable_user(), $values, array('pk_i_id' => $user_id, 'i_gdpr_tc' => $tc, 'i_gdpr_pp' => $pp, 'i_gdpr_nw' => $nw));
        if ($tc==1){
        return false;
        } else { 
        return true;
     }
   }

*

tomi327

  • ***
  • 66 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #10 on: September 10, 2021, 01:41:59 PM »
One very basic way is that. It is not tested so lets try.

// add it to model
Code: [Select]
public function getGdprByUserId( $user_id ) { 
$this->dao->select();
$this->dao->from( $this->getTable_t_user() );
$this->dao->where('pk_i_id', $user_id);

  $result = $this->dao->get();
    if( !$result ) {
       return array();
    } return $result->row();
}

// add it to item_post
Code: [Select]
<?php
$checkbox 
ModelGDPR::newInstance()->getGdprByUserId($user_id);
?>


<?php if ($checkbox ['i_gdpr_tc'] !== 1) {
      
// show gdpr checkboxes
      // thats your job ;-)
<?php ?>

« Last Edit: September 10, 2021, 02:52:02 PM by tomi327 »

*

MB Themes

Re: If socials logged in then require blablabla else relax :-)
« Reply #11 on: September 10, 2021, 02:53:10 PM »
@tomi327
Your code seems to be OK.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 475 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #12 on: September 11, 2021, 12:05:08 PM »
@tomi 327

 8) Looks good BIG thanks for that!  8) I am testing this right now and in item_post i got errors saying.

Fatal error: Uncaught Error: Call to undefined method ModelGDPR::getTable_t_user() changed to ModelGDPR::getTable_user() and is OK now...

Next there is still an error saying: Notice: Undefined variable: user_id in /home/u****/domains/wi***/public_html/testi/oc-content/themes/veronika/item-post.php on line 16

and Notice: Undefined index: i_gdpr_tc in line *****
 
i will keep on trying and keep you posted :-)
« Last Edit: September 11, 2021, 01:12:01 PM by mwindey »

*

MB Themes

Re: If socials logged in then require blablabla else relax :-)
« Reply #13 on: September 11, 2021, 01:00:33 PM »
@mwindey
That notice means:
- no record found
- or/ record found but it does not contains column i_gdpr_tc
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

tomi327

  • ***
  • 66 posts
Re: If socials logged in then require blablabla else relax :-)
« Reply #14 on: September 11, 2021, 01:26:24 PM »
Check if you have defined $user_id somewhere in item_post. If no try this.

Code: [Select]

<?php
$user_id 
osc_user_id();
$checkbox ModelGDPR::newInstance()->getGdprByUserId($user_id);
?>
 
« Last Edit: September 11, 2021, 01:30:20 PM by tomi327 »