2016-08-24 30 views
4

我有一個使用Joomla開發的公司頁面,裏面用PHP開發了一個行政區域。只有具有特定權限的用戶partnerpartner_employees才能訪問此區域。在wordpress頁面內的PHP區域

我需要將主站點遷移到Wordpress,並使用登錄名Wordpress在受限區域保持相同的行爲。

可能嗎?

我應該從哪個限制區域放置目錄?

如何把鏈接指向Wordpress頁面指向這個區域?

回答

5

如果你只是想呈現wpMy AccountPHP開發的禁區,而不是與wp整合(在你的情況Joomla)另一個框架,你可以簡單地實現,通過:

首先,創建wp templateincludes禁區邏輯。參考文獻:https://developer.wordpress.org/themes/basics/template-files/ https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

其次,使用創建的template創建wp page並在menu設置link此頁面。參考文獻:https://codex.wordpress.org/Pages

現在,如果你想與WordPress來處理身份驗證爲好,要麼你可以使用許多可用的插件在那裏,如:

  1. https://wordpress.org/plugins/advanced-access-manager/

  2. https://wordpress.org/plugins/wpfront-user-role-editor/

或者你可以自己定製代碼,知道更多你可以在這裏參考:https://codex.wordpress.org/Roles_and_Capabilities

你的模板文件可能看起來像(作爲起點):

<?php 
/** 
* Template Name: My Account Page Temp 
* 
* @package WordPress 
* @subpackage Twenty_Fourteen 
* @since Twenty Fourteen 1.0 
*/ 

<?php if (is_user_logged_in() && current_user_can($capability)): ?> 

//render your restricted area content   

<?php else : ?> 

// Redirect him for login 

<?php endif; ?> 

注意:您可以打破你的禁區邏輯的嵌套 template parts,可以每 你main template爲中使用它們要求。把它們放在你的活動主題目錄下: wp-content/themes/twentyfourteen/myaccount

<?php get_sidebar(); ?> 
<?php get_template_part('featured-content'); ?> 
<?php get_footer(); ?> 

希望這有助於。

+1

提示:'else:' - than --' endif;' – Spooky

相關問題