Osclass Support Forums

Osclass plugin support => Osclass GDPR Plugin => Topic started by: mwindey on September 07, 2021, 11:03:33 AM

Title: If socials logged in then require blablabla else relax :-)
Post by: mwindey 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

Title: Re: If socials logged in then require blablabla else relax :-)
Post by: MB Themes on September 07, 2021, 03:59:56 PM
@mwindey
You would have to check user record if tc/pp was checked.
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey 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
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey 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....
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: tomi327 on September 09, 2021, 12:40:14 PM
You need to check GDPR --> user_id ( Table = user ).
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey 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  :(
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: tomi327 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
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey 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);
    }
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: tomi327 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. :-)
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey 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;
     }
   }
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: tomi327 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 ?>

Title: Re: If socials logged in then require blablabla else relax :-)
Post by: MB Themes on September 10, 2021, 02:53:10 PM
@tomi327
Your code seems to be OK.
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey 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 :-)
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: MB Themes 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
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: tomi327 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);
?>
 
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: MB Themes on September 11, 2021, 01:43:34 PM
Osc_logged_user_id
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey on September 11, 2021, 03:35:40 PM
No more errors but now it ignores if ($checkbox ['i_gdpr_tc'] !== 1)
If it is 1 or 0 it continues with script.....
I tried to use the code also in form/checkbox.php but the same happens then.
Test to see if user id gets echoed is ok but it continues showing boxes.....  :-\ 
Code: [Select]
<?php
if(osc_is_web_user_logged_in() )
$user_id osc_user_id();
$checkbox ModelGDPR::newInstance()->getGdprByUserId($user_id);
if (
$checkbox ['i_gdpr_tc'] !== 1) {
echo 
"<h2>" $user_id "</h2>";
}  else { 
 
// redirect user to another page
    
header"location: https://osclasspoint.com" ); die;
?>
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: MB Themes on September 11, 2021, 03:49:33 PM
$checkbox['i_gdpr_tc'] != 1

Osc_usee_id does not seems to be ok
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey on September 11, 2021, 05:15:49 PM
@MB Themes, @tomi 327

Thanks guys for your support on this.....You both did it  8)
It finally works correctly now if user =1 in table user but since user is logged in with socials he/or she skipped table user and when adding a new listing table item gets updated..... The user still needs to check all boxes then.
Isn't it possible now that when a new listing is added table item and table user are getting updated at the same time?
 
Final code that works when table user is filled is:

Code: [Select]
<?php
$required_fields 
strtolower(osc_get_preference('post_required''veronika_theme'));
$user_id osc_logged_user_id();
$checkbox ModelGDPR::newInstance()->getGdprByUserId($user_id);
if (
$checkbox['i_gdpr_tc'] !=0) {
?>

Now i only need to look in model for a way to update both tables at the same time when adding a listing. 
Anyway for now .....
Me happy now :D :D
 
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: mwindey on September 13, 2021, 08:26:14 AM
My latest update did the trick to solve my problem completely.
Since i am not using table item for gdpr there is no need to fill it with $tc, $pp, $nw. Instead i am only using table user to fill and check if socials are logged and checked boxes.


In model i modified
Code: [Select]
// INSERT TC/PP ON ITEM
   public function updateItem($user_id, $tc, $pp, $nw) {
   if($user_id = osc_logged_user_id()  ) {
    $values = array(
      'i_gdpr_tc' => $tc,
      'i_gdpr_pp' => $pp,
      'i_gdpr_nw' => $nw
    );
    $this->dao->update($this->getTable_user(), $values, array('pk_i_id' => $user_id));
       }
    }



And checkbox.php checks if user has tc and pp on.....
Code: [Select]
<?php
$user_id 
osc_logged_user_id();
$checkbox ModelGDPR::newInstance()->getGdprByUserId($user_id);
if (
$checkbox['i_gdpr_tc'] !=1) {
?>
......continue script....

Halfway the page i copied the same code for boxes and made them tc and pp un-visible....it continues checking for $nw
Code: [Select]
  <?php }   }  else if ($checkbox['i_gdpr_nw'] !=1) { ?> and only box $nw is shown.

In the end when all 3 boxes are checked there is
Code: [Select]
  <?php }  else  {  ?> and some text to fill.
If logged in with any kind of media it works as a charm now.....
I am posting this just in case someone needs it.
All credits to tomi 327 and Frosticek @MB Themes


 
Title: Re: If socials logged in then require blablabla else relax :-)
Post by: MB Themes on October 21, 2021, 11:12:32 AM
New major version has been released just now, solving problem of users logged in via social networks.