Skip to content

Commit

Permalink
Merge pull request #84 from redbitcz/feature/jb-password-hint
Browse files Browse the repository at this point in the history
Rest: Better text for users which already have a account
  • Loading branch information
jakubboucek authored May 26, 2021
2 parents 50febc8 + c8041ee commit 0b7a877
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Redbit\SimpleShop\WpPlugin;

use WP_Error;
use WP_Post;
use WP_REST_Controller;
use WP_REST_Request;
use WP_REST_Response;
Expand Down Expand Up @@ -90,8 +89,6 @@ public function create_item( $request ) {
}

// Check if user with this email exists, if not, create a new user
$_login = $email;
$_password = '<a href="' . wp_lostpassword_url( get_bloginfo( 'url' ) ) . '">Změnit ho můžete zde</a>';
if ( ! email_exists( $email ) ) {
$_password = wp_generate_password( 8, false );

Expand All @@ -106,7 +103,6 @@ public function create_item( $request ) {
$userdata = apply_filters( 'ssc_new_user_data', $userdata );

$user_id = wp_insert_user( $userdata );
// wp_new_user_notification($user_id,$userdata['user_pass']); // poslani notifikacniho e-mailu

do_action( 'ssc_new_user_created', $user_id );

Expand All @@ -115,13 +111,19 @@ public function create_item( $request ) {
[ 'status' => 500, 'plugin_version' => SIMPLESHOP_PLUGIN_VERSION ] );
}
} else {
$_password = '<i>' . sprintf(
__(
'Your current password (which you set or we sent to you in a previous email). If you have lost your password, <a href="%s">you can reset it here</a>.',
'simpleshop-cz'
),
esc_attr( wp_lostpassword_url( get_bloginfo( 'url' ) ) )
) . '</i>';

// Get user_by email
$user = get_user_by( 'email', $email );
$user_id = $user->ID;
}

// Check if group exists
$user_groups = [];
foreach ( $request->get_param( 'user_group' ) as $group ) {
$ssc_group = new Group( $group );

Expand All @@ -133,8 +135,6 @@ public function create_item( $request ) {
$membership = new Membership( $user_id );
$valid_to = $request->get_param( 'valid_to' ) ?: '';
$membership->set_valid_to( $group, $valid_to );

$user_groups[] = $group;
}
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public function create_item_permissions_check( $request ) {
/**
* Prepare the item for the REST response
*
* @param mixed $item WordPress representation of the item.
* @param mixed $item WordPress representation of the item.
* @param WP_REST_Request $request Request object.
*
* @return mixed
Expand Down

0 comments on commit 0b7a877

Please sign in to comment.