Module: Wpxf::WordPress::User
- Defined in:
- lib/wpxf/wordpress/user.rb
Overview
Provides functionality required to gather information about users.
Instance Method Summary collapse
-
#wordpress_user_exists?(user) ⇒ Boolean
Checks if a user exists.
-
#wordpress_user_profile_form_fields(cookie) ⇒ Hash?
The profile form fields and their default values.
Instance Method Details
#wordpress_user_exists?(user) ⇒ Boolean
Checks if a user exists.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/wpxf/wordpress/user.rb', line 8 def wordpress_user_exists?(user) res = execute_post_request( url: wordpress_url_login, body: wordpress_login_post_body(user, Wpxf::Utility::Text.rand_alpha(6)) ) return true if res && res.code == 200 && ( res.body.to_s =~ /Incorrect password/ || res.body.to_s =~ /document\.getElementById\('user_pass'\)/ ) false end |
#wordpress_user_profile_form_fields(cookie) ⇒ Hash?
Returns the profile form fields and their default values.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wpxf/wordpress/user.rb', line 24 def wordpress_user_profile_form_fields() res = execute_get_request(url: wordpress_url_admin_profile, cookie: ) return nil unless res.code == 200 fields = {} res.body.scan(/<input.*?name="(.*?)".*?value="(.*?)".*?>/i) do |name, value| fields[name] = value end fields end |