I am working on a plugin that restricts validated users to viewing and reading content. Upon registering, I create metadata with an access_id of 99:
function tc_access_create_visitor($event, $object_type, $object) {
// add metadata
if (($object) && ($object instanceof ElggUser)) {
define("ACCESS_VISITOR",99);
create_metadata($object->guid, "visitor", "yes","", $object->guid, ACCESS_VISITOR);
}
}
Users cannot add or edit content (i.e., add blogs, create groups, send messages, etic.) until an admn "Activates" them by setting the access_id back to 2 using an activate action page. I see the change in the database for the user I activated. However, upon login the same user is still unable to add or edit content, eventhough the database has been updated with an access_id of 2.
I am using the following function in the start.php page to check for the access_id of 99:
register_plugin_hook('action', 'blog/add', 'tc_access_check_hook');
function tc_access_check_hook($hook, $entity_type, $returnvalue, $params) {
//global $CONFIG;
$user_id = get_loggedin_userid();
$count = "";
global $visitor_allowed;
$sql = "SELECT DISTINCT access_id FROM `elgg`.`elgg_metadata` WHERE entity_guid = '{$user_id}' AND access_id = '99' ";
$result = get_data($sql);
if (count($result) > 0) {
register_error(elgg_echo("Not allowed."));
forward($_SERVER['HTTP_REFERER']);
exit;
}
}
The code is not retrieving the updated access_id of 2 for the logged in user. Any comments you may have to read in the updated access_id is much appreciated.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- DhrupDeScoop@Dhrup2000

DhrupDeScoop - 0 likes
You must log in to post replies.print_r ($result);