Sunday, August 23, 2015

Use WordPress as CMS

WordPress is a popular blogging software. It has a lot of nice-looking themes. It will be very nice if it can be used as the framework of a website.

For this purpose, one should be able to create custom roles (user groups), members of such roles may or may not be able to post blogs, but can access custom pages once log in. Several things are crucial:

1) create custom role(s).
2) check if a user is logged in, and access user profile such as ID, login name, user name, email, user type. Based on this, one can add custom database tables and build whatever function that is desired.
3) make use of WordPress theme in custom page.

A study on these requirements proves fruitful. Over the weekend, I was able to build a member page for 4 WordPress themes. It's easy to extend to more themes.

The files are prepared and will be uploaded to github. See:

https://github.com/chenx/WordPress_Extension


Summary:
  • Shows how to check if a user is logged in, and retrieval user information.
  • Shows how to include header/footer of current theme.
  • To add custom links, go to Appearance -> Menus -> Custom Links
  • To allow user register, see [3] below.
    It seems Wordpress allows each user to have one role only. That's less flexible than .NET membership, which allows each user to have any roles.
  • To change default user registeration email, see [4].
  • To allow manage user roles, use the Members plugin [5].
  • To disable comments/discussion on a per-page basis:
    On Edit Page, click Screen Options and check the Discussion box. Then in Discussion section, uncheck "Allow comments".
  • To add a forum, see .
  • Note: installed themes are in wp-content/themes/
  • Note: to imitate other page's layout, see theme's page.php.
  • Note: to customize page title, see wp-includes/post-template.php function get_the_title().
References:
  1. http://codex.wordpress.org/Function_Reference/wp_get_current_user
  2. https://web-design-weekly.com/snippets/load-a-different-header-in-wordpress/
  3. http://www.wpbeginner.com/beginners-guide/how-to-allow-user-registration-on-your-wordpress-site/
  4. https://wordpress.org/plugins/welcome-email-editor/
  5. https://wordpress.org/plugins/members/
  6. wordpress - redirect to target page after log in 

No comments:

Blog Archive

Followers