Sha256: a15012503f261e3fde5d4da35f931b76645b9371559032d6b37ed4ff06ec966f

Contents?: true

Size: 988 Bytes

Versions: 2

Compression:

Stored size: 988 Bytes

Contents

require "active_record"

##
# This class is used for getting the user from the wordpress database
# 
# == Examples:
#   User.find(1).name
# The above will find the user with id of 1 and retrieve their display name

class User < ActiveRecord::Base
	set_table_name :wp_users
	set_primary_key :ID
	
	has_many :settings
	has_many :pages, :foreign_key => :post_author
	has_many :posts, :foreign_key => :post_author
	has_many :comments, :foreign_key => :user_id
	
	##
	# Grab the name of the selected user
	
	def name
		display_name
	end
	
	##
	# Set the name of the selected user
	
	def name= name
		self.display_name = name
	end
	
	##
	# Grab the username of the selected user
	
	def username
		user_login
	end
	
	##
	# Set the username of the selected user
	
	def username= username
		self.user_login = username
	end
	
	##
	# Grab the email of the selected user
	
	def email
		user_email
	end
	
	##
	# Set the email of the selected user
	
	def email= email
		self.user_email = email
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wpb-0.0.6.pre lib/wpb/user.rb
wpb-0.0.5 lib/wpb/user.rb