Filter User Accounts

5 posts by 2 authors in: Forums > CMS Builder
Last Post: March 23, 2020   (RSS)

By AlanAlonso - January 29, 2020

I need to hide a user from User Accounts List as a Super Admin

I tried to use the following code but is not working

<?php
/*
Plugin Name: Administracion
Description: Acceso administracion de usuarios
Version: 1.00
CMS Version Required: 3.00
*/

addFilter('list_where', 'filterUser', null, 2);

function filterUser($accessWhere, $tableName) {
  /* only check the accounts section */
  if ($tableName == 'accounts') { return $accessWhere; }
  
  $accessWhere .= " AND 'num' != '1' ";
  return $accessWhere;
}

?>

By daniel - February 7, 2020

Hi AlanAlonso,

It looks like you have the right idea but in the slightly wrong order. The line if ($tableName == 'accounts') { return $accessWhere; } will return the original "$accessWhere" variable if the table is "accounts" and skip the rest of the function. Try out this instead and let me know if it does the trick:

function filterUser($accessWhere, $tableName) {
  /* only check the accounts section */
  if ($tableName == 'accounts') { 
    $accessWhere .= " AND 'num' != '1' ";
  }
  
  return $accessWhere;
}

Thanks,

Daniel
Technical Lead
interactivetools.com

By AlanAlonso - February 11, 2020

Hi Daniel,

First of all thank you for the reply, the code is still not working, I upload the file to plugins folder, then I activate the plugin and set Required Plugins at the Advanced tab on Section Editors.

By daniel - February 18, 2020

Hi AlanAlonso,

This is, unfortunately, a difficult issue to troubleshoot over the forums. If you can support a 2nd level support request with your CMS/FTP details (https://www.interactivetools.com/support/request/) we can take a look directly and have an easier time seeing what's going on.

Thanks!

Daniel
Technical Lead
interactivetools.com

By AlanAlonso - March 23, 2020 - edited: March 23, 2020

Fixed

$accessWhere .= " AND `num` != '1' ";