Untitled
unknown
plain_text
2 years ago
2.2 kB
8
Indexable
<?php
defined( 'ABSPATH' ) || exit;
/*
* @hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email );
$first_name = '';
if (isset($email->recipient)){
$user = get_user_by('email', $email->recipient);
if (isset($user->ID)){
$first_name = get_user_meta($user->ID, 'billing_first_name', true);
}
}
if (!empty($first_name)){
echo esc_html__('Hi ','b2bking').$first_name;
echo '<br>';
}
?>
<p>
<?php esc_html_e( 'Congratulations! Your account has been approved.', 'b2bking'); ?>
<br />
</p>
<?php
/**
* Show user-defined additional content - this is set in each email's settings.
*/
if ( $additional_content ) {
echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
}
?>
<p><?php printf( esc_html__( 'Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: %3$s', 'woocommerce' ), esc_html( $blogname ), '<strong>' . esc_html( $user_login ) . '</strong>', make_clickable( esc_url( wc_get_page_permalink( 'myaccount' ) ) ) );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php
function generate_set_password_link( $user_id ) {
// Make sure the user ID is valid
if ( ! is_numeric( $user_id ) || $user_id <= 0 ) {
return 'Invalid user ID.';
}
// Get the user object
$user = get_user_by( 'id', $user_id );
// Check if the user exists
if ( ! $user ) {
return 'User not found.';
}
// Generate the reset key
$reset_key = get_password_reset_key( $user );
// Check if there was an error generating the reset key
if ( is_wp_error( $reset_key ) ) {
return 'Error generating reset key.';
}
// Create the WooCommerce lost password URL
$reset_url = wc_get_page_permalink( 'myaccount' ) . 'lost-password/?key=' . $reset_key . '&login=' . rawurlencode( $user->user_login );
return $reset_url;
}
// Usage example
echo '<br>Click here to <a href="'.generate_set_password_link( $user->ID ).'">set your password.</a>';
/*
* @hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );Editor is loading...
Leave a Comment