Functions.php added code not working

Vi ER konsulenter
15 Posts
Vi ER konsulenter posted this 15 November 2017

Hello,

I have the plugin client portal. I wanted my users to get an email when I update their private page, so I asked the developer of the plugin. I can add the following code to my functions.php:

//Send an email to the user when his private page was updated 
function cpc_send_email_on_page_update($post_id) {
$author_id = get_post_field('post_author', $post_id);

$user = get_userdata($author_id);
$to = $user->user_email;
$site_name = get_bloginfo('name');

$subject = '['.$site_name.'] Private page updated !';
$message = 'Your private page was just updated !';

wp_mail($to, $subject, $message);
}
add_action( 'save_post_private-page', 'cpc_send_email_on_page_update' );

When I activate the twenty seventeen theme the extra code in the functions.php works fine. But when I activate the Themler theme I made, it does not work.

I added the code in the functions.php of both the Twenty Seventeen theme and my Themler theme.

Does anyone know what can be the problem?

Hello, I have the plugin client portal. I wanted my users to get an email when I update their private page, so I asked the developer of the plugin. I can add the following code to my functions.php: //Send an email to the user when his private page was updated function cpc_send_email_on_page_update($post_id) { $author_id = get_post_field('post_author', $post_id); $user = get_userdata($author_id); $to = $user->user_email; $site_name = get_bloginfo('name'); $subject = '['.$site_name.'] Private page updated !'; $message = 'Your private page was just updated !'; wp_mail($to, $subject, $message); } add_action( 'save_post_private-page', 'cpc_send_email_on_page_update' ); When I activate the twenty seventeen theme the extra code in the functions.php works fine. But when I activate the Themler theme I made, it does not work. I added the code in the functions.php of both the Twenty Seventeen theme and my Themler theme. Does anyone know what can be the problem?
Vote to pay developers attention to this features or issue.
6 Comments
Order By: Standard | Newest
Support Team
Support Team posted this 15 November 2017

Hi,

Did you try adding the code to the Themler Settings >> CMS Code?
This is the proper place to add custom php and usually everything work ok.

Thank you,
Olivia

Hi, Did you try adding the code to the Themler Settings >> CMS Code? This is the proper place to add custom php and usually everything work ok. Thank you, Olivia
Vi ER konsulenter
15 Posts
Vi ER konsulenter posted this 15 November 2017

I did not try that, but I did just now.

I get an error saying it is unrecognised code.

I did not try that, but I did just now. I get an error saying it is unrecognised code.
Support Team
Support Team posted this 15 November 2017

Hi,

I've tried to add it to the WP theme on my side and it does not return any error messages. Are you sure that you added it exactly into the CMS Code field?

Thank you,
Olviia

Hi, I've tried to add it to the WP theme on my side and it does not return any error messages. Are you sure that you added it exactly into the CMS Code field? Thank you, Olviia
Vi ER konsulenter
15 Posts
Is Solution
Vi ER konsulenter posted this 15 November 2017

Thnx Olivia, that was the problem, I accidentaly used the field for extra CSS in stead of CMS code.

I managed to get the code in and the code is also working.

Thnx Olivia, that was the problem, I accidentaly used the field for extra CSS in stead of CMS code. I managed to get the code in and the code is also working.
Support Team
Support Team posted this 16 November 2017

Hi,

Great!
Please let us know if you have any other questions/issues.

Thank you,
Olivia

Hi, Great! Please let us know if you have any other questions/issues. Thank you, Olivia
alexturkonline
1 Posts
alexturkonline posted this 22 March 2025

It sounds like a theme-related conflict! Since the code works fine in Twenty Seventeen but not in Themler, the issue might be with how Themler handles post updates or custom hooks. Check if ESS Utumishi Portal or any other plugin in your setup interferes with save_post_private-page. Also, ensure functions.php in Themler is correctly executed. Adding error_log('Function triggered'); inside cpc_send_email_on_page_update might help debug if the function runs at all. Hope this helps!

It sounds like a theme-related conflict! Since the code works fine in Twenty Seventeen but not in Themler, the issue might be with how Themler handles post updates or custom hooks. Check if [ESS Utumishi Portal][1] or any other plugin in your setup interferes with save_post_private-page. Also, ensure functions.php in Themler is correctly executed. Adding error_log('Function triggered'); inside cpc_send_email_on_page_update might help debug if the function runs at all. Hope this helps! [1]: https://essutumishiportal.co.tz/
You must log in or register to leave comments