Functions.php added code not working

rianne
10 Posts
rianne 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.
5 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
rianne
10 Posts
rianne 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
rianne
10 Posts
Is Solution
rianne 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 5 weeks ago

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
You must log in or register to leave comments