SlideShare una empresa de Scribd logo
1 de 70
Descargar para leer sin conexión
WORDPRESSで作る
会員管理システム
マルチメディア⼯工房 陽
とある学会の会員管理
• 1000⼈人弱の会員を管理する
• 年に1〜~2度発⾏行物がある
• 年会費の⼊入⾦金処理がある
• 担当者は⼀一⼈人 ←
とある学会の会員管理
• 1000⼈人弱の会員を管理する
• 年に1〜~2度発⾏行物がある
• 年会費の⼊入⾦金処理がある
• 担当者は⼀一⼈人 ←担当者は⼀一⼈人 ←
担当者は⼀一⼈人
しかも本業は別
( ゜Д゜)ポカーン
とある学会の会員管理
• 1000⼈人弱の会員を管理する
• 年に1〜~2度発⾏行物がある
• 年会費の⼊入⾦金処理がある
• 担当者は⼀一⼈人
• それをエクセルで ←
とある学会の会員管理
• 1000⼈人弱の会員を管理する
• 年に1〜~2度発⾏行物がある
• 年会費の⼊入⾦金処理がある
• 担当者は⼀一⼈人
• それをエクセルで ←それをエクセルで ←
それをエクセルで
( ゜Д゜)ポカーン
そこで⼀一⼈人の漢(オトコ)が
⽴立ち上がった
古川 陽⼀一
こうして僕たちの戦い
が始まったのだった
第⼀一部 完
つづく
改めて
• エクセルで会員管理
• 会員数は1000⼈人弱
• 年次処理(⼊入会、退会、休会、⼊入⾦金)アリ
• 住所に向けて発⾏行物あり
エクセルは便利だけど…
• エクセル != システム
• エクセル != データベース
エクセルで管理すると…
• あちこちでフォーマットがぐちゃぐちゃ
• どの項⺫⽬目を列挙するか定まらない
• いわゆるモデリングができていない
• データがどこにあるか分からない
エクセルで管理すると…
• ⼊入⼒力が⼤大変
• でもオートフィルは便利
• 履歴の管理不可
• 複数⼈人運⽤用不可
古川さんの提案したこと
• Webシステムで作る
• データベースで管理
• 帳票とかの出⼒力が可能
• 絞り込み検索可能
• いわゆる会員管理システム
会員管理システム
• システム業界では良くある事例
• 顧客だったり、製品だったり、商品だった
り
• ○○管理システム
• 帳票とかもよく必要とされる
帳票 って皆さんご存じです?
• 業務に関わる書類のこと
• ⾒見積書、請求書、給与明細、⼀一覧表など
• 例1) 三⽉月に仕⼊入れた品物⼀一覧
• 例2) 当⽉月の全社員分の給与明細
昔からあるシステム
• 30年ほど前
• オフコン、DB2、COBOL…
• 15年ほど前
• VBA、Access…
• 最近だと
• Webでの管理システム
WEBでの管理システム
• ブラウザで操作可能
• 昔はそうじゃなかった!
• パソコンを限定されない
• 複数⼈人アクセス可能
会員管理システムって何が必要?
• 1000⼈人ほど会員がいて
• 会員には名前とか住所とかの属性があって
• 会員ごとに絞り込みとかかけて
• 印刷したい
うーん⼤大変そうだなぁ…
あれ?でもこれ
WORDPRESSで
⾏行けそうじゃん?
会員管理システムって何が必要?
• 会員ごとに絞り込みとかかけて
• => WP_Queryとか
• 印刷したい
• => テーブルレイアウトとCSS
会員管理システムって何が必要?
• 1000⼈人ほど会員がいて
• => カスタム投稿タイプ
• 会員には名前とか住所とかの属性があって
• => カスタムフィールド
いける!
WORDPRESSなら
• ログイン周りOK
• 編集画⾯面OK
• テーマあるから流⽤用できちゃう
• 並び変えとかも結構できちゃう
というわけで
WORDPRESSでの開発を
決めました
第⼆二部 完
つづく
第三部
こんなのできました
作ってみたまとめ
• ⽤用意されてる機能が豊富なので早い
• フルスクラッチ開発(ゼロから開発)するよ
り圧倒的に早い
• カスタム投稿タイプとかそれなりにつくっ
てくれる
第四部
開発で使ったテクニック
問題
• postmetaで並び変えしたい
• しかも複数のキーで並び変えしたい
• 例) 会員番号 + ⽣生年⽉月⽇日
ぶっちゃけ
• ⽣生のSQLなら余裕なのに…
• ORDER BY meta1 DESC, meta2 ASC など
• WordPressで⽤用意されているorderby
• metakeyは⼀一つだけ
ソースコードを⾒見てみると
• 本体のコードだとmeta_key⼀一つしか来ない前
提のコード
• 書き換えたい衝動に駆られる
本体のコードを変えると…
• アップデートごとに当てなければならない
パッチ
• そして当たらなくなるパッチ
• (もういいや…、アップデートは諦めよう)
本体への改変
イコール
地獄の第⼀一歩(確信)
それにしても
• 本体改変 => アップデートできなくなる
• どこかで聞いたような…
テーマ
⼦子テーマ
⼦子テーマを使うと
• ⼦子テーマには親テーマとの差分のみを記述
する
• 書き換えた箇所以外のアップデートであれ
ばそのままでおk
本体のコードでも
同じ事ができないだろうか…
できます!
アクションフック
アクションフック(フィルター)
• WordPressで決められた箇所で、特定の処理
を⾏行いますよーって宣⾔言されたもの
• the_contentを呼び出すときにはthe_contentっ
てフィルターを呼びますよ
• じゃぁ僕the_contentへ全部富⼭山弁にするフィ
ルター書いちゃおう 的な
アクションフック(フィルター)
• フックやフィルターの箇所
• API
• API⼀一覧は公開されてます
が、ORDERBYは無い
APIが無い…
• 年々APIの数は増えているけれども、要望の
少ない箇所、処理がフクザツな箇所はAPIが
無い
• orderbyとかかなり内部的な所なのでAPI無し
でもここで負けてらんない
(数⽇日前)
古川さん「ここ並び変えさせたい
けどできる?⼤大変かな?」
ぼく「⼤大丈夫ですよ古川さん、僕
WORDPRESSの事ならだいたいなん
でもできます」
⾏行った⼿手前、後には引けない
会員番号 ⼊入会年⽉月⽇日
1 2010-10-10
2 1999-07-01
15 2011-03-03
30 2014-04-01
1992-02-02
2008-01-01
2002-07-28
2012-08-15
空欄はnull
会員番号 ⼊入会年⽉月⽇日
1 2010-10-10
2 1999-07-01
15 2011-03-03
30 2014-04-01
1992-02-02
2008-01-01
2002-07-28
2012-08-15
空欄はnull
ここを
会員番号 ⼊入会年⽉月⽇日
1 2010-10-10
2 1999-07-01
15 2011-03-03
30 2014-04-01
1992-02-02
2002-07-28
2008-01-01
2012-08-15
空欄はnull
こうしたい
改めて問題は
• 本体を書き換えればorderbyできる
• でも書き換えると運⽤用に⽀支障(ずっとパッチ
or アップデート不可)
• 専⽤用のプラグインを作って呼び出す
• それはコスト(⽇日数 = お⾦金)がかかる
ということで
• 本体を書き換えつつ
• アップデートに耐えられる仕様
メソッドオーバーライド
メソッドオーバーライド
• クラスのメソッドを上書きする機能
• クラスの他の部分には影響を与えない
• => アップデートに強い
やってみた
• WP_Queryクラスを継承したMy_WP_Query
クラスを作成
• parse_orderbyというメソッドを上書き
• 使う箇所ではMy_WP_Queryのインスタンス
を利⽤用
会員番号 ⼊入会年⽉月⽇日
1 2010-10-10
2 1999-07-01
15 2011-03-03
30 2014-04-01
1992-02-02
2002-07-28
2008-01-01
2012-08-15
空欄はnull
ばっちり!
実際には
• metakeyを⼆二つ使うにはテーブルを⼆二つjoinする必要がある
• 独⾃自のキーワードだけに反応
• ‘orderby’ => array(‘meta_key’ => ‘member_code’);
• とかを
• ‘orderby’ => array(‘my_metakey’ => ‘something’);
• にする
使うにあたって
• 本体のソースコードを注意深く読む
• デーブル構成を把握する
• ⽣生成されるSQLを把握する
• debugbar最⾼高
• 努⼒力あるのみ
振り返って
• メソッドオーバーライド⾃自体はそんなにス
ゴイテクニックじゃ無い
• でもWordPressだと情報が少なし
• WordPress以外、PHP以外にも⼿手を広げると
良いことあるよ
振り返って
• WordPress以外のシステムも使ってみると良
い
• フレームワークとか
• フルスクラッチ開発をすると基礎が⾝身につ
く
• DBばかりに注⼒力するのもよし
でも
• ⼤大変なシステムは丸投げでおk
• エンジニアがフヒヒとか⾔言ってやってくれる
• WordBenchには豊富な⼈人材が揃っています
最後に
• WordPressでも⼗十分システム開発できるよ
• WordPressなら開発早いよ
• WordPressで挫けそうな時でも頑張ればなん
とかなったりするよ
• それでもダメなら⼈人に頼ろう
お疲れ様でした

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Word bench富山4月富山市 wordpressで作る会員管理システム