effective_learndash 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a995bb252c9977d587fad29eb85ed7a700e14623000545f40f86c5ef11578e3
4
- data.tar.gz: a8e0082d8e0db22298325ba7bfc074e01ef0f244063e7e4725058dcac0bf704d
3
+ metadata.gz: 0c988c1953adabbfc3e8bac44c28a11575423e93ffcd216e76c70c8a7045be09
4
+ data.tar.gz: db782e5f5971a1098d3f5268e3218c34341f567971d8159c9a3e431a06f612c2
5
5
  SHA512:
6
- metadata.gz: c4b47b748dcb01abb40f39f7a2db372e15c9ddc872a98f78afb7e6dddd10b4b404c3dbc280d82895ac2b7cb593622292a201e791dbb7f720ad4b4137eb8968da
7
- data.tar.gz: 5278f678c4e13c4e08ed936fc53e7d9e3225e8db1ff3b663abf6acc67589001cd39b120a4d802abace3ad9e3710b88f10e676074f10fea7c6c1dd8ee5dbd27af
6
+ metadata.gz: 577324f8a74fbc1622327c97e83efef53bb67aaaf2e506805ac697b25be8ad43a197a6b373d33c1061f0f81ea6526d9123c5e4a7e4eb89ebc44a3a21725c3ada
7
+ data.tar.gz: ca4487a5aec94110d60ec5872d1806d96b1c3ef3fa0111c4c65ab7d6c914ae63008c5fcb44e472485b1548bdd033a1080757926d71b9024534827927e2d8b6d2
data/README.md CHANGED
@@ -115,6 +115,12 @@ There are no webhooks or callbacks from LearnDash, everything is a GET request t
115
115
 
116
116
  You can refresh an entire LearnDash user in one operation and it will sync the entire user at once, `user.learndash_user.refresh!`
117
117
 
118
+ ## Delete User
119
+
120
+ If you need to delete a user, from wordpress:
121
+
122
+ 1. Top Left Corner -> My Sites -> Network Admin -> Users
123
+
118
124
  ## License
119
125
 
120
126
  MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
@@ -7,5 +7,13 @@ module Admin
7
7
 
8
8
  on :refresh, success: -> { "Successfully refreshed #{resource} and all course enrollments" }
9
9
 
10
+ submit :update_password, 'Update Password'
11
+
12
+ private
13
+
14
+ def permitted_params
15
+ params.require(:effective_learndash_user).permit!
16
+ end
17
+
10
18
  end
11
19
  end
@@ -52,6 +52,17 @@ module Effective
52
52
  nil
53
53
  end
54
54
 
55
+ def update_password(owner, password)
56
+ raise('expected a leardash owner') unless owner.class.respond_to?(:effective_learndash_owner?)
57
+ raise('expected an existing learndash user') unless owner.learndash_user&.persisted?
58
+ raise('expected a password') unless password.present?
59
+
60
+ user = user_id(owner) || raise('expected a user')
61
+ payload = { password: password }
62
+
63
+ post("/wp/v2/users/#{user}", payload.stringify_keys)
64
+ end
65
+
55
66
  # Create User
56
67
  # Usernames can only contain lowercase letters (a-z) and numbers.
57
68
  def create_user(owner)
@@ -98,5 +98,11 @@ module Effective
98
98
  assign_attributes(last_synced_at: Time.zone.now)
99
99
  end
100
100
 
101
+ def update_password!
102
+ save!
103
+ EffectiveLearndash.api.update_password(owner, password)
104
+ true
105
+ end
106
+
101
107
  end
102
108
  end
@@ -1,6 +1,16 @@
1
1
  = effective_form_with(model: [:admin, learndash_user], engine: true) do |f|
2
2
 
3
- = f.select :owner, {'Owners' => current_user.class.sorted }, polymorphic: true,
4
- hint: 'Create a LearnDash account for this user'
3
+ - if f.object.new_record?
4
+ = f.select :owner, {'Owners' => current_user.class.sorted }, polymorphic: true,
5
+ hint: 'Create a LearnDash account for this user'
5
6
 
6
- = f.submit
7
+ = f.submit
8
+
9
+ - if f.object.persisted?
10
+ = f.text_field :password, label: 'New Password',
11
+ value: EffectiveLearndash.wp_password_for(learndash_user.owner)
12
+
13
+ %p.text-muted
14
+ This action will also update the LearnDash LMS wordpress user account password.
15
+
16
+ = f.submit 'Update Password'
@@ -3,12 +3,18 @@
3
3
  = link_to(learndash_user.owner, "/admin/users/#{learndash_user.owner.to_param}/edit")
4
4
  has an existing account on LearnDash.
5
5
 
6
+ %p= link_to "LearnDash LMS User Admin", EffectiveLearndash.learndash_url.chomp('/') + "/wp-admin/user-edit.php?user_id=#{learndash_user.user_id}", target: '_blank'
7
+
6
8
  %ul
7
9
  %li Email: #{learndash_user.email}
8
10
  %li Username: #{learndash_user.username}
9
- %li Password: #{learndash_user.password}
11
+ %li
10
12
 
11
- %p= link_to "LearnDash LMS User Admin", EffectiveLearndash.learndash_url.chomp('/') + "/wp-admin/user-edit.php?user_id=#{learndash_user.user_id}", target: '_blank'
13
+ Password: #{learndash_user.password}
14
+
15
+ = collapse('change password', card_class: 'my-2') do
16
+ .row
17
+ .col-lg-4= render('admin/learndash_users/form', learndash_user: learndash_user)
12
18
 
13
19
  %p
14
20
  %small Last refreshed #{time_ago_in_words(learndash_user.last_synced_at)} ago.
@@ -1,3 +1,3 @@
1
1
  module EffectiveLearndash
2
- VERSION = '0.1.9'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_learndash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-12 00:00:00.000000000 Z
11
+ date: 2022-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails