The registered user gets the "Author" access rights. Through the menu, you can make the button "Create material" and the Author, having entered the site, can create this material. This is understandable.
It is necessary that the Author, by pressing a button in his profile, could create a Category, having only title
and alias
.
How to implement this in Joomla 4? Everything that I find is outdated and does not work.
=================================
In file: templates/mytemplate/html/com_users/profile/default.php there is a button and a script
$(".url").click(function(){
var url = $("#basic-url").val();
var idbtnclick1 = $(this).attr('id');
$.ajax({
type: 'post',
url: "/property/profile/page.php",
data: {
'user': "<?php echo $user ?>",
'url': url,
'command': idbtnclick1
},
response: 'text',
//location.reload();
//success: function(data){
// $("#eddd").html(data);
//}
})
//console.log(url);
});
File: /property/profile/page.php
define('_JEXEC', 1);
define('JPATH_BASE', realpath(dirname(__FILE__) . '/../..'));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
$user = $_POST["user"];
$url = $_POST["url"];
$command = $_POST["command"];
if ($command === 'urlplus') {
/* ???????????????????????????????????????????????? */
}
if ($command === 'urledit') {
$object = new stdClass();
$object->title = $user;
$object->alias = $url;
$object->path = $url;
$object->modified_user_id = 419;
$object->modified_time = null;
$result = JFactory::getDbo()->updateObject('#__categories', $object, 'title');
}
The part where the changes are made works. We need to do the part that creates the new category. Found an example and similar ones but don't work.