Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password field based on WooCommerce settings #1977

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions includes/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
*
* @return void
*/
function dokan_store_category_menu( $seller_id, $title = '' ) {

Check warning on line 660 in includes/template-tags.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The method parameter $title is never used
?>
<div class="store-cat-stack-dokan cat-drop-stack">
<?php
Expand Down Expand Up @@ -952,17 +952,22 @@
* @return string[]
*/
function dokan_get_seller_registration_form_data() {
$set_password = get_option( 'woocommerce_registration_generate_password', 'no' ) !== 'yes';

// prepare form data
$data = [
'fname' => '',
'lname' => '',
'username' => '',
'email' => '',
'phone' => '',
'password' => '',
'shopname' => '',
'shopurl' => '',
];

if ( $set_password ) {
$data['password'] = '';
}
// check if user submitted data
if ( isset( $_POST['woocommerce-register-nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['woocommerce-register-nonce'] ) ), 'woocommerce-register' ) ) {
$data = [
Expand All @@ -971,10 +976,12 @@
'username' => isset( $_POST['username'] ) ? sanitize_user( wp_unslash( $_POST['username'] ) ) : '',
'email' => isset( $_POST['email'] ) ? sanitize_email( wp_unslash( $_POST['email'] ) ) : '',
'phone' => isset( $_POST['phone'] ) ? sanitize_text_field( wp_unslash( $_POST['phone'] ) ) : '',
'password' => isset( $_POST['password'] ) ? wp_unslash( $_POST['password'] ) : '', // phpcs:ignore
'shopname' => isset( $_POST['shopname'] ) ? sanitize_text_field( wp_unslash( $_POST['shopname'] ) ) : '',
'shopurl' => isset( $_POST['shopurl'] ) ? sanitize_title( wp_unslash( $_POST['shopurl'] ) ) : '',
];
if ( $set_password ) {
$data['password'] = isset( $_POST['password'] ) ? wp_unslash( $_POST['password'] ) : ''; // phpcs:ignore;
}
}

return $data;
Expand Down
5 changes: 5 additions & 0 deletions templates/account/vendor-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<label for="reg_email"><?php esc_html_e( 'Email address', 'dokan-lite' ); ?> <span class="required">*</span></label>
<input type="email" class="input-text form-control" name="email" id="reg_email" value="<?php echo ! empty( $data['email'] ) ? esc_attr( $data['email'] ) : ''; ?>" required="required" />
<label class="reg_email_error"></label>
<?php if ( get_option( 'woocommerce_registration_generate_password', 'no' ) === 'yes' ) : ?>
<small><?php echo __( 'A link to set a new password will be sent to your email address.', 'dokan-lite' ); ?></small>
<?php endif; ?>
</p>

<p class="form-row form-group form-row-wide">
Expand All @@ -35,10 +38,12 @@
<input type="hidden" name="role" value="seller">
</p>

<?php if ( get_option( 'woocommerce_registration_generate_password', 'no' ) !== 'yes' ) : ?>
<p class="form-row form-group form-row-wide">
<label for="reg_password"><?php esc_html_e( 'Password', 'dokan-lite' ); ?> <span class="required">*</span></label>
<input type="password" class="input-text form-control" name="password" id="reg_password" value="<?php echo ! empty( $data['password'] ) ? esc_attr( $data['password'] ) : ''; ?>" required="required" minlength="6" />
</p>
<?php endif; ?>

<!-- Spam Trap -->
<div style="left:-999em; position:absolute;"><label for="trap"><?php esc_html_e( 'Anti-spam', 'dokan-lite' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div>
Expand Down
Loading