Greetings,
I am working on making the custom changes in article: https://piwigo.org/doc/doku.php?id=user … last_names
I changed the content of register.tpl and indentification.tpl in /themes/default/template directory.
I then used LocalFiles Editor to paste the content into Personal Plugin below (between */ and ?>):
- - - - - - - - - -
<?php
/*
Plugin Name: Personal Plugin
Version: 1.0
Description: Personal Plugin
Plugin URI: http://piwigo.org
Author:
Author URI:
*/
add_event_handler('init', 'id_fam');
function id_fam(){
global $template, $user;
$template->assign(array( 'F_KEY' => get_ephemeral_key(6) ));
if (isset($_POST['firstname']) and isset($_POST['lastname']))
{
$_POST['login']=ucwords(strtolower(strip_tags($_POST['firstname']))).' '.ucwords(strtolower(strip_tags($_POST['lastname'])));
$_POST['username']=ucwords(strtolower(strip_tags(($_POST['firstname']))).' '.ucwords(strtolower(strip_tags(($_POST['lastname'])));
$template->assign(array( 'F_LASTNAME' => $_POST['lastname'], 'F_FIRSTNAME' => $_POST['firstname'] ));
}
}
?>
- - - - - - - - - -
When I save the file, I receive the error message:
Parse error: syntax error, unexpected ';', expecting ')' in /home/epnet29info/public_html/pwg/plugins/LocalFilesEditor/include/functions.inc.php(45) : eval()'d code on line 19
I tried removing the semicolon from what I think is line 19 (begjns $_POST['username']). Also adding another close parenthesis both with and without the semicolon, but I still receive similar error messages.
Any suggestions?
Ron
Piwigo version: 2.10.2
PHP version: 7.4.8
MySQL version: 10.2.32-MariaDB
Piwigo URL: http://equinephotographers.info/pwg/
Offline
Please post code as code blocks (see here) so we can see the actual code and not what appears to be arbitrarily line-wrapped.
My assumption: you copy-pasted the code already line-wrapped without knowing what it is supposed to do. The newlines before the '.ucwords(... should actually be spaces instead.
Offline
Sorry about that. Let me try again. This is the full Personal Plugin text:
<?php /* Plugin Name: Personal Plugin Version: 1.0 Description: Personal Plugin Plugin URI: http://piwigo.org Author: Author URI: */ add_event_handler('init', 'id_fam'); function id_fam(){ global $template, $user; $template->assign(array( 'F_KEY' => get_ephemeral_key(6) )); if (isset($_POST['firstname']) and isset($_POST['lastname'])) { $_POST['login']=ucwords(strtolower(strip_tags($_POST['firstname']))).' '.ucwords(strtolower(strip_tags($_POST['lastname']))); $_POST['username']=ucwords(strtolower(strip_tags(($_POST['firstname']))).' '.ucwords(strtolower(strip_tags(($_POST['lastname']))); $template->assign(array( 'F_LASTNAME' => $_POST['lastname'], 'F_FIRSTNAME' => $_POST['firstname'] )); } } ?>
Which is what it looks like in LocalFiles Editor as well as the documentation. And you are correct. I know what it is supposed to do in concept and can generally see the function but do not know the coding technique - not sure what all the parentheses do and why they are not paired. Willing to learn though.
Offline
This line
$_POST['username']=ucwords(strtolower(strip_tags(($_POST['firstname']))).' '.ucwords(strtolower(strip_tags(($_POST['lastname'])));
should be
$_POST['username']=ucwords(strtolower(strip_tags($_POST['firstname']))).' '.ucwords(strtolower(strip_tags($_POST['lastname'])));
instead (note the erroneous extra '(' parentheses in front of both $_POST).
And yes, it's already wrong in the documentation.
Offline
Thank you erAck, "File written successfully."
I should have compared the two lines and noted the issue but was too busy looking for an errant semicolon.
Your help is most appreciated!
Ron
Offline