effective_learndash 0.1.8 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/app/controllers/admin/learndash_users_controller.rb +8 -0
- data/app/models/concerns/effective_learndash_course_registration.rb +2 -7
- data/app/models/effective/learndash_api.rb +11 -0
- data/app/models/effective/learndash_user.rb +6 -0
- data/app/views/admin/learndash_users/_form.html.haml +13 -3
- data/app/views/admin/learndash_users/_learndash_user.html.haml +8 -2
- data/lib/effective_learndash/engine.rb +1 -1
- data/lib/effective_learndash/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076d625d658223be135f56e74dc7f7c6e6e077688f2ed38a51f7ac4eb88b1233
|
4
|
+
data.tar.gz: 94849221f3f64496dcff99ee3f8a313d3143a809c750ca62edcceabbb204b68d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1a22b8cedfb1eb29584a114373991dfc1acab6b544326ccb24456d7b9078e535d449d828d25ce6390a5e69b3f78c725eef08e8e3f6689da2269f79073f0da93
|
7
|
+
data.tar.gz: 47841e76f2d3d4a7185e44b8a49ff3eccb186f3229eb9472715770ce4f6355dae60a684e2f455feb6da35167513aee669ddd97b2d40a0b52a58d2feb21a003b6
|
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
|
@@ -87,8 +87,9 @@ module EffectiveLearndashCourseRegistration
|
|
87
87
|
course_registrants
|
88
88
|
end
|
89
89
|
|
90
|
-
#
|
90
|
+
# Create learndash user and enroll in all courses
|
91
91
|
def after_submit_purchased!
|
92
|
+
learndash_owner.create_learndash_user
|
92
93
|
course_registrants.each { |registrant| registrant.owner.create_learndash_enrollment(course: registrant.learndash_course) }
|
93
94
|
end
|
94
95
|
|
@@ -155,12 +156,6 @@ module EffectiveLearndashCourseRegistration
|
|
155
156
|
|
156
157
|
# Save record
|
157
158
|
save!
|
158
|
-
|
159
|
-
# Create a learndash user now before payment to catch any errors in server stuff before payment.
|
160
|
-
learndash_owner.create_learndash_user
|
161
|
-
raise('expected a persisted learndash user') unless learndash_owner.learndash_user&.persisted?
|
162
|
-
|
163
|
-
true
|
164
159
|
end
|
165
160
|
|
166
161
|
private
|
@@ -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)
|
@@ -1,6 +1,16 @@
|
|
1
1
|
= effective_form_with(model: [:admin, learndash_user], engine: true) do |f|
|
2
2
|
|
3
|
-
|
4
|
-
|
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
|
-
|
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
|
11
|
+
%li
|
10
12
|
|
11
|
-
|
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.
|
@@ -13,7 +13,7 @@ module EffectiveLearndash
|
|
13
13
|
|
14
14
|
# Include acts_as_addressable concern and allow any ActiveRecord object to call it
|
15
15
|
initializer 'effective_learndash.active_record' do |app|
|
16
|
-
|
16
|
+
app.config.to_prepare do
|
17
17
|
ActiveRecord::Base.extend(EffectiveLearndashOwner::Base)
|
18
18
|
ActiveRecord::Base.extend(EffectiveLearndashCourseRegistration::Base)
|
19
19
|
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
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2022-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|