Reset Password Email Template Wordpress - wordpress

I have Requirement to change the reset password email template, i have checked the woocommerece email settings and it is on for the reset email from there, but issue is when user request to reset the password it is generating email from there, but using the email content form Wordpress core File
wp-include > user.php
attached it is the screenshot as well.
What i have to do it to remove following section
Regards,
All at ###SITENAME###
So how i can achieve it and if there is any possibilities to enable the Woocommerece template somehow so can directly copy template in my child theme and customize it there?

You can use password_change_email filter for customizing text.
add_filter( 'password_change_email', 'change_password_mail_message', 10, 3 );
function change_password_mail_message(
$pass_change_mail,
$user,
$userdata
) {
$new_message_txt = __( 'Your Text' );
$pass_change_mail[ 'message' ] = $new_message_txt;
return $pass_change_mail;
}

Related

Request method of wp setting and option api

I am building a plugin. For rendering the menu page both Option API & Setting API are used. Below is my callback function for add_menu_page()
<?php
//Calback function for add menu page
function render_newsletter_admin() {
if(!current_user_can( 'manage_options' )){
return;
}
if($_SERVER["REQUEST_METHOD"]=="GET"){
add_settings_error( 'newsletter', 'newsletter', __( 'Settings Saved', 'victory' ), 'success' );
settings_errors( );
}
?>
<div class="wrap">
<form action="options.php" method="post">
<?php
// output security fields for the registered setting "wporg"
settings_fields( 'newsletter' );
// output setting sections and their fields
// (sections are registered for "wporg", each field is registered to a specific section)
do_settings_sections( 'newsletter' );
// output save settings button
submit_button( 'Save Settings' );
?>
</form>
</div>
<?php
}
Notice that method attribute of the form set to POST but to add setting error $_SERVER["REQUEST_METHOD"]=="GET" is being checked and it is working. Shouldn't it be checked against POST?
Shouldn't it be checked against POST?
It's checked against GET instead of POST because the form is being submitted to and handled by options.php (or more precisely, wp-admin/options.php), and after the submission is processed, WordPress will redirect the user back to the origin of the submission which is the menu page having that form. Therefore the request method would then be GET.
Illustration of how the request method changed (from GET to POST then back to GET)
User landed on the menu page (the request method is GET).
Then he/she submitted the form.
The browser submits the form to options.php, using the POST method.
Now on the options.php page, the request method is POST.
And after the form submission is processed, WordPress sends the user back to the menu/form page.
Now on the menu page, the request method is GET because the above redirect uses that method.
Relevant code in wp-admin/options.php
So at the top in wp-admin/options.php, it says...
/**
* Options Management Administration Screen.
*
* If accessed directly in a browser this page shows a list of all saved options
* along with editable fields for their values. Serialized data is not supported
* and there is no way to remove options via this page. It is not linked to from
* anywhere else in the admin.
*
* This file is also the target of the forms in core and custom options pages
* that use the Settings API. In this case it saves the new option values
* and returns the user to their page of origin.
*
* #package WordPress
* #subpackage Administration
*/
And on lines 339-341 (https://core.trac.wordpress.org/browser/tags/5.8/src/wp-admin/options.php#L339):
// Redirect back to the settings page that was submitted.
$goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() );
wp_redirect( $goback );
And if you look at the "complete example" in the plugin developer handbook, it's actually also checking against GET whereby add_settings_error() is called only if $_GET['settings-updated'] is set:
// add error/update messages
// check if the user have submitted the settings
// WordPress will add the "settings-updated" $_GET parameter to the url
if ( isset( $_GET['settings-updated'] ) ) {
// add settings saved message with the class of "updated"
add_settings_error( 'wporg_messages', 'wporg_message', __( 'Settings Saved', 'wporg' ), 'updated' );
}
// show error/update messages
settings_errors( 'wporg_messages' );
Also, you might want to call settings_errors() outside the if (like above), and pass newsletter as the first parameter for the function, i.e. do settings_errors( 'newsletter' ).

How to display a field in user meta in default WordPress registration form

I have a requirement where I wish to show a field office_name in WordPress default registration form.
What I did so far: I have created a field called 'office_name' by using the following code:
function my_show_extra_profile_fields() {
$user_contact_method['office_name'] = 'name of your office';
$user_contact_method['office_location'] = 'location of your office';
return $user_contact_method;
}
add_filter( 'user_contactmethods', 'my_show_extra_profile_fields' );
The office_name field is appearing in the USERS tab in the back end and getting updated when I enter the values there.
I want it to appear in the registration form.
You need to customize your registration form . Here is the Wordpress codex link.
https://codex.wordpress.org/Customizing_the_Registration_Form

How to remove password strength checker from wordpress profile and reset password page

I am using wordpress 4.5.2, and I wants to remove password strength checker from profile page. I just need new password and confirm password field instead of password strength checker
use this code
function wc_ninja_remove_password_strength() {
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) {
wp_dequeue_script( 'wc-password-strength-meter' );
}
}
add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 );
To do this, add this function in your
functions.php file
in
wp-content/themes/your-theme-name/:

Woocommerce New Customer Admin Notification Email

I am building an ecommerce site using Wordpress and Woocommerce. I need the site to send out a notification email to the site administrator when a new customer account is registered. I thought this functionality would be built into Woocommerce since it uses the Wordpress user account structure and Wordpress sends new user notifications, but it doesn't appear to be. Does anyone know of a plugin or a function I can use to add this functionality? Thanks!
I'm assuming that you are using html inside emails. If you are using plain text the procedure is similar.
You need to override the woocommerce template structure. Here you can find how: http://docs.woothemes.com/document/template-structure/.
Actually the only file you need to override is your_template_directory/woocommerce/emails/customer-new-account.php.
At the end of this file add this line of code:
<?php do_action( 'new_customer_registered', $user_login ); ?>
In functions.php add this:
function new_customer_registered_send_email_admin($user_login) {
ob_start();
do_action('woocommerce_email_header', 'New customer registered');
$email_header = ob_get_clean();
ob_start();
do_action('woocommerce_email_footer');
$email_footer = ob_get_clean();
woocommerce_mail(
get_bloginfo('admin_email'),
get_bloginfo('name').' - New customer registered',
$email_header.'<p>The user '.esc_html( $user_login ).' is registered to the website</p>'.$email_footer
);
}
add_action('new_customer_registered', 'new_customer_registered_send_email_admin');
add_action('woocommerce_created_customer', 'admin_email_on_registration', 10 , 1);
function admin_email_on_registration( $customer_id) {
wp_new_user_notification( $customer_id );
}
woocommerce_created_customer is hook which is called when user created by woocommerce. It only sends notification to customer. we will use wp_new_user_notification() function to send notification to Admin.
I was pulling my hair out trying to figure this same issue out and after going back and forth with the developers the default is to not send new customer registration notification emails to admin.
After trying various email plugins and even resorting to using WP SMTP Email, I finally decided to leave it alone.
That said, WooCommerce 2.0 was released today so it may be built in the new version.
the answers is in the emails sections of "woocommerce / settings"
simply change the from email to wordpress#yourdomain.com
worked for me as i also had the same issues
To notify admin whn new user has registered use:
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id )
{
wp_send_new_user_notifications( $customer_id, 'admin' );
}
See documentation on https://woocommerce.com/document/notify-admin-new-account-created/

How to change the title of comment form in drupal

At my website there is "Login or register to post comments.."
I want to change the message to:
"Login or register to post comments(comments will be moderated).."
Because plenty of spammers are just creating logins to post spam comments.
Although all comments are moderated now. Putting this message will give clear info that spamming may not be possible and spammers will not create logins.
Assuming you are using Drupal 6, the code that creates the comment form is in the file comments.module in the Drupal module directory. Fortunately, the function allows for theming.
What you can do is copy and paste the function theme_comment_post_forbidden($node) and place it in the template.php file in your theme directory. You will also need to rename the function, replacing 'theme' with your theme name.
For example, say your theme name is 'utilitiesindia'. Then you will rename your function to utilitiesindia_comment_post_forbidden.
So, in your template.php file in a theme named utilitiesindia, use this function:
/**
* Theme a "you can't post comments" notice.
*
* #param $node
* The comment node.
* #ingroup themeable
*/
function utiltiesindia_comment_post_forbidden($node) {
global $user;
static $authenticated_post_comments;
if (!$user->uid) {
if (!isset($authenticated_post_comments)) {
// We only output any link if we are certain, that users get permission
// to post comments by logging in. We also locally cache this information.
$authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));
}
if ($authenticated_post_comments) {
// We cannot use drupal_get_destination() because these links
// sometimes appear on /node and taxonomy listing pages.
if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
$destination = 'destination='. rawurlencode("comment/reply/$node->nid#comment-form");
}
else {
$destination = 'destination='. rawurlencode("node/$node->nid#comment-form");
}
if (variable_get('user_register', 1)) {
// Users can register themselves.
return t('Login or register to post comments(comments will be moderated)', array('#login' => url('user/login', array('query' => $destination)), '#register' => url('user/register', array('query' => $destination)))
);
}
else {
// Only admins can add new users, no public registration.
return t('Login to post comments', array('#login' => url('user/login', array('query' => $destination))));
}
}
}
}
how to change the comment link text " Login or register to post comment" to be shorter ,eg " comment"
Also you can use String overrides module.
In Drupal 6:
Another option is to create a small custom module. This uses hook_link_alter(). This is a small example module to change the title of the "Login to post new comment" link: (Replace every instance of MYMODULE_NAME with the name you choose for the module)
STEP 1: Create a file called MYMODULE_NAME.info and add:
; $Id$
name = "MYMODULE_NAME"
description = "Change the appearance of links that appear on nodes"
core = 6.x
STEP 2: Create file called MYMODULE_NAME.module and add:
<?php
// $Id$;
/**
* Implementation of hook_link_alter
*/
function MYMODULE_NAME_link_alter(&$links, $node){
if (!empty($links['comment_forbidden'])) {
// Set "Login to post new comment" link text
$links['comment_forbidden']['title'] = 'NEW TEXT';
// Add this to allow HTML in the link text
$links['comment_forbidden']['html'] = TRUE;
}
}
STEP 3: Put these files in a folder called MYMODULE_NAME, place the folder in sites/all/modules, and enable the module
If you actually want to stop spammers from creating accounts, you should use something like the CAPTCHA module, since they typically use bots that will ignore instructions in any case.
http://drupal.org/project/captcha

Resources