Fix user regsiter form & user roles
This commit is contained in:
parent
2e48bafe16
commit
8ef01f3c21
@ -1,3 +1,6 @@
|
|||||||
|
= 1.3.6 - 2020-02-29 =
|
||||||
|
* Fixes - User register form & User roles
|
||||||
|
|
||||||
= 1.3.5 - 2020-02-28 =
|
= 1.3.5 - 2020-02-28 =
|
||||||
* Added - Time format setting
|
* Added - Time format setting
|
||||||
* Added - Hide unset amenities settings
|
* Added - Hide unset amenities settings
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* $Desc$
|
* $Desc$
|
||||||
*
|
*
|
||||||
@ -11,177 +11,189 @@
|
|||||||
* @website http://www.wpopal.com
|
* @website http://www.wpopal.com
|
||||||
* @support http://www.wpopal.com/support/forum.html
|
* @support http://www.wpopal.com/support/forum.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit; // Exit if accessed directly
|
exit; // Exit if accessed directly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class OpalEstate_Admin_User{
|
class OpalEstate_Admin_User {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpalEstate_Admin_User constructor.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'cmb2_admin_init', [ $this, 'register_user_profile_metabox' ] );
|
||||||
|
add_action( 'personal_options', [ $this, 'show_message_user_profile' ] );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct( ){
|
public function show_message_user_profile() {
|
||||||
|
|
||||||
add_action( 'cmb2_admin_init', array( $this, 'register_user_profile_metabox') );
|
|
||||||
add_action( 'personal_options', array( $this, 'show_message_user_profile' ) );
|
|
||||||
|
|
||||||
|
$user_id = isset( $_GET['user_id'] ) ? intval( $_GET['user_id'] ) : 0;
|
||||||
|
$roles = opalestate_user_roles_by_user_id( $user_id );
|
||||||
|
|
||||||
|
if ( $roles ):
|
||||||
|
if ( in_array( 'opalestate_agency', $roles ) ):
|
||||||
|
$agency_id = get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
|
||||||
|
if ( ! $agency_id ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$link = get_edit_post_link( $agency_id );
|
||||||
|
?>
|
||||||
|
<div id="message" class="updated fade">
|
||||||
|
<p><?php echo sprintf( __( 'This user has role <strong>Opal Estate Agency</strong> and click here to <a href="%s">update Agency profile</a>', 'opalestate-pro' ), $link ); ?></p>
|
||||||
|
</div>
|
||||||
|
<?php elseif ( in_array( 'opalestate_agent', $roles ) ) :
|
||||||
|
$agent_id = get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
|
||||||
|
if ( ! $agent_id ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$link = get_edit_post_link( $agent_id );
|
||||||
|
?>
|
||||||
|
<div id="message" class="updated fade">
|
||||||
|
<p><?php echo sprintf( __( 'This user has role <strong>Opal Estate Agent</strong> and click here to <a href="%s">update Agent profile</a>', 'opalestate-pro' ), $link ); ?></p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function show_message_user_profile(){
|
public function shortcode_button() {
|
||||||
|
|
||||||
$user_id = isset( $_GET['user_id'] ) ? intval( $_GET['user_id'] ) : 0;
|
|
||||||
$roles = opalestate_user_roles_by_user_id( $user_id );
|
|
||||||
|
|
||||||
if( $roles ):
|
|
||||||
if( in_array( 'opalestate_agency', $roles) ):
|
|
||||||
$agency_id = get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
|
|
||||||
if( !$agency_id ){
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
$link = get_edit_post_link( $agency_id );
|
|
||||||
?>
|
|
||||||
<div id="message" class="updated fade">
|
|
||||||
<p><?php echo sprintf( __('This user has role <strong>Opal Estate Agency</strong> and click here to <a href="%s">update Agency profile</a>', 'opalestate-pro'), $link ); ?></p>
|
|
||||||
</div>
|
|
||||||
<?php elseif( in_array( 'opalestate_agent', $roles) ) :
|
|
||||||
$agent_id = get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
|
|
||||||
if( !$agent_id ){
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
$link = get_edit_post_link( $agent_id );
|
|
||||||
?>
|
|
||||||
<div id="message" class="updated fade">
|
|
||||||
<p><?php echo sprintf( __('This user has role <strong>Opal Estate Agent</strong> and click here to <a href="%s">update Agent profile</a>', 'opalestate-pro'), $link ); ?></p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
endif;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function shortcode_button(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook in and add a metabox to add fields to the user profile pages
|
* Hook in and add a metabox to add fields to the user profile pages
|
||||||
*/
|
*/
|
||||||
public function register_user_profile_metabox() {
|
public function register_user_profile_metabox() {
|
||||||
global $pagenow;
|
global $pagenow;
|
||||||
|
|
||||||
if( $pagenow == 'profile.php' || $pagenow == 'user-new.php' || 'user-edit.php' ){
|
if ( $pagenow == 'profile.php' || $pagenow == 'user-new.php' || $pagenow == 'user-edit.php' ) {
|
||||||
|
if ( $pagenow == 'profile.php' && ! opalestate_current_user_can_access_dashboard_page() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $pagenow == 'user-edit.php' ) {
|
||||||
|
$user_id = isset( $_GET['user_id'] ) ? absint( $_GET['user_id'] ) : 0;
|
||||||
|
if ( ! $user_id ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! opalestate_user_has_estate_roles( $user_id ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$prefix = OPALESTATE_USER_PROFILE_PREFIX;
|
$prefix = OPALESTATE_USER_PROFILE_PREFIX;
|
||||||
|
|
||||||
$metabox = new Opalestate_User_MetaBox();
|
$metabox = new Opalestate_User_MetaBox();
|
||||||
|
|
||||||
$box_options = array(
|
$box_options = [
|
||||||
'id' => $prefix . 'edit',
|
'id' => $prefix . 'edit',
|
||||||
'title' => esc_html__( 'Metabox', 'opalestate-pro' ),
|
'title' => esc_html__( 'Metabox', 'opalestate-pro' ),
|
||||||
'object_types' => array( 'user' ),
|
'object_types' => [ 'user' ],
|
||||||
'show_names' => true,
|
'show_names' => true,
|
||||||
);
|
];
|
||||||
|
|
||||||
$cmb = new_cmb2_box( $box_options );
|
$cmb = new_cmb2_box( $box_options );
|
||||||
|
|
||||||
// Setting tabs
|
// Setting tabs
|
||||||
$tabs_setting = array(
|
$tabs_setting = [
|
||||||
'config' => $box_options,
|
'config' => $box_options,
|
||||||
'layout' => 'vertical', // Default : horizontal
|
'layout' => 'vertical', // Default : horizontal
|
||||||
'tabs' => array()
|
'tabs' => [],
|
||||||
);
|
];
|
||||||
|
|
||||||
|
$tabs_setting['tabs'][] = [
|
||||||
$tabs_setting['tabs'][] = array(
|
|
||||||
'id' => 'p-general',
|
'id' => 'p-general',
|
||||||
'icon' => 'dashicons-admin-home',
|
'icon' => 'dashicons-admin-home',
|
||||||
'title' => esc_html__( 'General', 'opalestate-pro' ),
|
'title' => esc_html__( 'General', 'opalestate-pro' ),
|
||||||
'fields' => $this->get_base_fields()
|
'fields' => $this->get_base_fields(),
|
||||||
);
|
];
|
||||||
|
|
||||||
$tabs_setting['tabs'][] = array(
|
$tabs_setting['tabs'][] = [
|
||||||
'id' => 'p-socials',
|
'id' => 'p-socials',
|
||||||
'icon' => 'dashicons-share',
|
'icon' => 'dashicons-share',
|
||||||
'title' => esc_html__( 'Socials', 'opalestate-pro' ),
|
'title' => esc_html__( 'Socials', 'opalestate-pro' ),
|
||||||
'fields' => $metabox->get_social_fields( $prefix ),
|
'fields' => $metabox->get_social_fields( $prefix ),
|
||||||
);
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set tabs
|
// Set tabs
|
||||||
$cmb->add_field( array(
|
$cmb->add_field( [
|
||||||
'id' => '__tabs',
|
'id' => '__tabs',
|
||||||
'type' => 'tabs',
|
'type' => 'tabs',
|
||||||
'tabs' => $tabs_setting
|
'tabs' => $tabs_setting,
|
||||||
) );
|
] );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metabox for the user profile screen
|
* Metabox for the user profile screen
|
||||||
*/
|
*/
|
||||||
$cmb_user = new_cmb2_box( array(
|
$cmb_user = new_cmb2_box( [
|
||||||
'id' => $prefix . 'edit',
|
'id' => $prefix . 'edit',
|
||||||
'title' => esc_html__( 'User Profile Metabox', 'cmb2' ), // Doesn't output for user boxes
|
'title' => esc_html__( 'User Profile Metabox', 'cmb2' ), // Doesn't output for user boxes
|
||||||
'object_types' => array( 'user' ), // Tells CMB2 to use user_meta vs post_meta
|
'object_types' => [ 'user' ], // Tells CMB2 to use user_meta vs post_meta
|
||||||
'show_names' => true,
|
'show_names' => true,
|
||||||
'new_user_section' => 'add-new-user', // where form will show on new user page. 'add-existing-user' is only other valid option.
|
'new_user_section' => 'add-new-user', // where form will show on new user page. 'add-existing-user' is only other valid option.
|
||||||
) );
|
] );
|
||||||
|
|
||||||
$fields = $this->extra_info_fields();
|
$fields = $this->extra_info_fields();
|
||||||
foreach( $fields as $field ){
|
foreach ( $fields as $field ) {
|
||||||
$cmb_user->add_field( $field );
|
$cmb_user->add_field( $field );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_base_fields(){
|
public function get_base_fields() {
|
||||||
$prefix = OPALESTATE_USER_PROFILE_PREFIX;
|
$prefix = OPALESTATE_USER_PROFILE_PREFIX;
|
||||||
|
|
||||||
$metabox = new Opalestate_User_MetaBox();
|
$metabox = new Opalestate_User_MetaBox();
|
||||||
$fields = array_merge_recursive(
|
$fields = array_merge_recursive(
|
||||||
$metabox->get_base_fields( $prefix ),
|
$metabox->get_base_fields( $prefix ),
|
||||||
$metabox->get_job_fields( $prefix ) ,
|
$metabox->get_job_fields( $prefix ),
|
||||||
$metabox->get_address_fields( $prefix )
|
$metabox->get_address_fields( $prefix )
|
||||||
);
|
);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function extra_info_fields(){
|
public function extra_info_fields() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$prefix = OPALESTATE_USER_PROFILE_PREFIX;
|
$prefix = OPALESTATE_USER_PROFILE_PREFIX;
|
||||||
|
|
||||||
$management = array();
|
$management = [];
|
||||||
|
|
||||||
|
|
||||||
$admin_fields = array();
|
|
||||||
$admin_fields[] = array(
|
|
||||||
'id' => "{$prefix}block_submission",
|
|
||||||
'name' => esc_html__( 'Block Submssion', 'opalestate-pro' ),
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'description' => esc_html__( 'Disable Submssion Functions to not allow submit property', 'opalestate-pro' ),
|
|
||||||
'before_row' => '<hr>'
|
|
||||||
|
|
||||||
);
|
|
||||||
$admin_fields[] = array(
|
|
||||||
'id' => "{$prefix}block_submission_msg",
|
|
||||||
'name' => esc_html__( 'Block Submssion Message', 'opalestate-pro' ),
|
|
||||||
'type' => 'textarea',
|
|
||||||
'description' => esc_html__( 'Show message for disabled user', 'opalestate-pro' ),
|
|
||||||
);
|
|
||||||
$management = array_merge_recursive( $admin_fields, $management );
|
|
||||||
|
|
||||||
|
|
||||||
return $management;
|
$admin_fields = [];
|
||||||
}
|
$admin_fields[] = [
|
||||||
|
'id' => "{$prefix}block_submission",
|
||||||
|
'name' => esc_html__( 'Block Submssion', 'opalestate-pro' ),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'description' => esc_html__( 'Disable Submssion Functions to not allow submit property', 'opalestate-pro' ),
|
||||||
|
'before_row' => '<hr>',
|
||||||
|
|
||||||
|
];
|
||||||
|
$admin_fields[] = [
|
||||||
|
'id' => "{$prefix}block_submission_msg",
|
||||||
|
'name' => esc_html__( 'Block Submssion Message', 'opalestate-pro' ),
|
||||||
|
'type' => 'textarea',
|
||||||
|
'description' => esc_html__( 'Show message for disabled user', 'opalestate-pro' ),
|
||||||
|
];
|
||||||
|
$management = array_merge_recursive( $admin_fields, $management );
|
||||||
|
|
||||||
|
|
||||||
|
return $management;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new OpalEstate_Admin_User();
|
new OpalEstate_Admin_User();
|
||||||
|
@ -34,7 +34,6 @@ class Opalestate_User_MetaBox {
|
|||||||
'type' => 'uploader',
|
'type' => 'uploader',
|
||||||
'single' => 1,
|
'single' => 1,
|
||||||
'limit' => 1,
|
'limit' => 1,
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => 'first_name',
|
'id' => 'first_name',
|
||||||
@ -65,7 +64,7 @@ class Opalestate_User_MetaBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_avatar_fields( $prefix ) {
|
public function get_avatar_fields( $prefix ) {
|
||||||
return [
|
return apply_filters( 'opalestate_get_user_matabox_avatar_fields', [
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Avatar Picture', 'opalestate-pro' ),
|
'name' => esc_html__( 'Avatar Picture', 'opalestate-pro' ),
|
||||||
'desc' => esc_html__( 'This image will display in user detail and profile box information', 'opalestate-pro' ),
|
'desc' => esc_html__( 'This image will display in user detail and profile box information', 'opalestate-pro' ),
|
||||||
@ -74,7 +73,7 @@ class Opalestate_User_MetaBox {
|
|||||||
'avatar' => true,
|
'avatar' => true,
|
||||||
|
|
||||||
],
|
],
|
||||||
];
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_address_fields( $prefix ) {
|
public function get_address_fields( $prefix ) {
|
||||||
|
@ -188,7 +188,7 @@ class OpalEstate_User_Search {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function dashboard_menu( $menu ) {
|
public function dashboard_menu( $menu ) {
|
||||||
if ( 'on' === opalestate_get_option( 'enable_dashboard_savedsearch', 'on' ) ) {
|
if ( opalestate_current_user_can_access_dashboard_page( 'savedsearch' ) && 'on' === opalestate_get_option( 'enable_dashboard_savedsearch', 'on' ) ) {
|
||||||
$menu['savedsearch'] = [
|
$menu['savedsearch'] = [
|
||||||
'icon' => 'fa fa-search',
|
'icon' => 'fa fa-search',
|
||||||
'link' => 'saved_search',
|
'link' => 'saved_search',
|
||||||
|
@ -63,7 +63,6 @@ class OpalEstate_User {
|
|||||||
}
|
}
|
||||||
$this->enable_extra_profile = opalestate_options( 'enable_extra_profile', 'on' );
|
$this->enable_extra_profile = opalestate_options( 'enable_extra_profile', 'on' );
|
||||||
|
|
||||||
|
|
||||||
add_action( 'init', [ $this, 'process_frontend_submit' ], 99999 );
|
add_action( 'init', [ $this, 'process_frontend_submit' ], 99999 );
|
||||||
add_action( 'cmb2_render_text_password', [ $this, 'cmb2_render_text_password' ], 10, 5 );
|
add_action( 'cmb2_render_text_password', [ $this, 'cmb2_render_text_password' ], 10, 5 );
|
||||||
|
|
||||||
@ -160,9 +159,9 @@ class OpalEstate_User {
|
|||||||
|
|
||||||
public function disable() {
|
public function disable() {
|
||||||
if ( ! current_user_can( 'manage_options' ) ) {
|
if ( ! current_user_can( 'manage_options' ) ) {
|
||||||
add_action( 'wp_before_admin_bar_render', [ $this, 'disable_profile_page' ] );
|
// add_action( 'wp_before_admin_bar_render', [ $this, 'disable_profile_page' ] );
|
||||||
add_action( 'admin_init', [ $this, 'disable_profile_page' ] );
|
// add_action( 'admin_init', [ $this, 'disable_profile_page' ] );
|
||||||
add_filter( 'show_admin_bar', '__return_false' );
|
add_filter( 'show_admin_bar', [ $this, 'disable_admin_bar' ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,6 +169,19 @@ class OpalEstate_User {
|
|||||||
add_action( 'opalestate_user_content_profile_page', [ $this, 'user_profile' ] );
|
add_action( 'opalestate_user_content_profile_page', [ $this, 'user_profile' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function disable_admin_bar( $show_admin_bar ) {
|
||||||
|
if ( is_user_logged_in() ) {
|
||||||
|
$current_user = wp_get_current_user();
|
||||||
|
$roles = $current_user->roles;
|
||||||
|
|
||||||
|
if ( in_array( 'opalestate_agent', $roles ) || in_array( 'opalestate_agency', $roles ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $show_admin_bar;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -303,7 +315,7 @@ class OpalEstate_User {
|
|||||||
public static function get_user_types() {
|
public static function get_user_types() {
|
||||||
|
|
||||||
return apply_filters( 'opalestate_usertypes', [
|
return apply_filters( 'opalestate_usertypes', [
|
||||||
'none' => esc_html__( 'Subscriber', 'opalestate-pro' ),
|
'subscriber' => esc_html__( 'Subscriber', 'opalestate-pro' ),
|
||||||
'opalestate_agent' => esc_html__( 'Agent', 'opalestate-pro' ),
|
'opalestate_agent' => esc_html__( 'Agent', 'opalestate-pro' ),
|
||||||
'opalestate_agency' => esc_html__( 'Agency', 'opalestate-pro' ),
|
'opalestate_agency' => esc_html__( 'Agency', 'opalestate-pro' ),
|
||||||
] );
|
] );
|
||||||
|
@ -69,7 +69,14 @@ function opalestate_get_user_tab_uri( $tab ) {
|
|||||||
|
|
||||||
|
|
||||||
function opalestate_management_show_content_page_tab() {
|
function opalestate_management_show_content_page_tab() {
|
||||||
$tab = isset( $_GET['tab'] ) && $_GET['tab'] ? sanitize_text_field( $_GET['tab'] ) : 'dashboard';
|
$tab = isset( $_GET['tab'] ) && $_GET['tab'] ? sanitize_text_field( $_GET['tab'] ) : 'dashboard';
|
||||||
|
|
||||||
|
if ( ! opalestate_current_user_can_access_dashboard_page( $tab ) ) {
|
||||||
|
echo opalestate_load_template_path( 'user/error' );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$tab_hook = $tab;
|
$tab_hook = $tab;
|
||||||
$tab_hook = apply_filters( 'opalestate_user_content_tab_hook', $tab_hook, $tab );
|
$tab_hook = apply_filters( 'opalestate_user_content_tab_hook', $tab_hook, $tab );
|
||||||
$fnc = 'opalestate_user_content_' . $tab_hook . '_page';
|
$fnc = 'opalestate_user_content_' . $tab_hook . '_page';
|
||||||
@ -122,9 +129,8 @@ function opalestate_my_account_page( $id = false, $args = [] ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function opalestate_submssion_page( $id = false, $args = [] ) {
|
function opalestate_submssion_page( $id = false, $args = [] ) {
|
||||||
|
|
||||||
|
|
||||||
$page = get_permalink( opalestate_get_option( 'submission_page', '/' ) );
|
$page = get_permalink( opalestate_get_option( 'submission_page', '/' ) );
|
||||||
|
|
||||||
if ( $id ) {
|
if ( $id ) {
|
||||||
$edit_page_id = opalestate_get_option( 'submission_edit_page' );
|
$edit_page_id = opalestate_get_option( 'submission_edit_page' );
|
||||||
$page = $edit_page_id ? get_permalink( $edit_page_id ) : $page;
|
$page = $edit_page_id ? get_permalink( $edit_page_id ) : $page;
|
||||||
@ -177,12 +183,12 @@ function opalestate_get_user_dashboard_menus() {
|
|||||||
|
|
||||||
$menu['dashboard'] = [
|
$menu['dashboard'] = [
|
||||||
'icon' => 'fas fa-chart-line',
|
'icon' => 'fas fa-chart-line',
|
||||||
'link' => 'dashboard',
|
'link' => opalestate_current_user_can_access_dashboard_page( 'dashboard' ) ? 'dashboard' : get_dashboard_url(),
|
||||||
'title' => esc_html__( 'Dashboard', 'opalestate-pro' ),
|
'title' => esc_html__( 'Dashboard', 'opalestate-pro' ),
|
||||||
'id' => isset( $opalestate_options['profile_page'] ) ? $opalestate_options['profile_page'] : 0,
|
'id' => isset( $opalestate_options['profile_page'] ) ? $opalestate_options['profile_page'] : 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ( 'on' === opalestate_get_option( 'enable_dashboard_profile', 'on' ) ) {
|
if ( opalestate_current_user_can_access_dashboard_page( 'profile' ) && 'on' === opalestate_get_option( 'enable_dashboard_profile', 'on' ) ) {
|
||||||
$menu['profile'] = [
|
$menu['profile'] = [
|
||||||
'icon' => 'far fa-user',
|
'icon' => 'far fa-user',
|
||||||
'link' => 'profile',
|
'link' => 'profile',
|
||||||
@ -191,7 +197,7 @@ function opalestate_get_user_dashboard_menus() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'on' === opalestate_get_option( 'enable_dashboard_favorite', 'on' ) ) {
|
if ( opalestate_current_user_can_access_dashboard_page( 'favorite' ) && 'on' === opalestate_get_option( 'enable_dashboard_favorite', 'on' ) ) {
|
||||||
$menu['favorite'] = [
|
$menu['favorite'] = [
|
||||||
'icon' => 'far fa-heart',
|
'icon' => 'far fa-heart',
|
||||||
'link' => 'favorite',
|
'link' => 'favorite',
|
||||||
@ -200,7 +206,7 @@ function opalestate_get_user_dashboard_menus() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'on' === opalestate_get_option( 'enable_dashboard_reviews', 'on' ) ) {
|
if ( opalestate_current_user_can_access_dashboard_page( 'reviews' ) && 'on' === opalestate_get_option( 'enable_dashboard_reviews', 'on' ) ) {
|
||||||
$menu['reviews'] = [
|
$menu['reviews'] = [
|
||||||
'icon' => 'far fa-star',
|
'icon' => 'far fa-star',
|
||||||
'link' => 'reviews',
|
'link' => 'reviews',
|
||||||
@ -209,7 +215,7 @@ function opalestate_get_user_dashboard_menus() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'on' === opalestate_get_option( 'message_log', 'on' ) ) {
|
if ( opalestate_current_user_can_access_dashboard_page( 'messages' ) && 'on' === opalestate_get_option( 'message_log', 'on' ) ) {
|
||||||
$menu['messages'] = [
|
$menu['messages'] = [
|
||||||
'icon' => 'fa fa-envelope',
|
'icon' => 'fa fa-envelope',
|
||||||
'link' => 'messages',
|
'link' => 'messages',
|
||||||
@ -218,7 +224,7 @@ function opalestate_get_user_dashboard_menus() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'on' === opalestate_get_option( 'enable_dashboard_submission', 'on' ) ) {
|
if ( opalestate_current_user_can_access_dashboard_page( 'submission' ) && 'on' === opalestate_get_option( 'enable_dashboard_submission', 'on' ) ) {
|
||||||
$menu['submission'] = [
|
$menu['submission'] = [
|
||||||
'icon' => 'fa fa-upload',
|
'icon' => 'fa fa-upload',
|
||||||
'link' => 'submission',
|
'link' => 'submission',
|
||||||
@ -227,7 +233,7 @@ function opalestate_get_user_dashboard_menus() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'on' === opalestate_get_option( 'enable_dashboard_properties', 'on' ) ) {
|
if ( opalestate_current_user_can_access_dashboard_page( 'myproperties' ) && 'on' === opalestate_get_option( 'enable_dashboard_properties', 'on' ) ) {
|
||||||
$statistics = new OpalEstate_User_Statistics();
|
$statistics = new OpalEstate_User_Statistics();
|
||||||
|
|
||||||
$menu['myproperties'] = [
|
$menu['myproperties'] = [
|
||||||
@ -308,3 +314,59 @@ if ( ! function_exists( 'opalestate_create_user' ) ) {
|
|||||||
function opalestate_get_user_meta( $user_id, $key, $single = true ) {
|
function opalestate_get_user_meta( $user_id, $key, $single = true ) {
|
||||||
return get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . $key, $single );
|
return get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . $key, $single );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current user can access dashboard page?
|
||||||
|
*
|
||||||
|
* @param $page
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function opalestate_current_user_can_access_dashboard_page( $page = '' ) {
|
||||||
|
if ( ! is_user_logged_in() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_user = wp_get_current_user();
|
||||||
|
$roles = $current_user->roles;
|
||||||
|
$allowd_roles = opalestate_get_allowed_roles();
|
||||||
|
|
||||||
|
foreach ( $roles as $role ) {
|
||||||
|
if ( in_array( $role, $allowd_roles ) ) {
|
||||||
|
return apply_filters( 'opalestate_opalestate_user_can_access', true, $role, $page );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User has estate roles?
|
||||||
|
*
|
||||||
|
* @param $user_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function opalestate_user_has_estate_roles( $user_id ) {
|
||||||
|
$user_meta = get_userdata( $user_id );
|
||||||
|
$roles = $user_meta->roles;
|
||||||
|
$allowd_roles = opalestate_get_allowed_roles();
|
||||||
|
|
||||||
|
foreach ( $roles as $role ) {
|
||||||
|
if ( in_array( $role, $allowd_roles ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get allowed roles for dashboard page.
|
||||||
|
*/
|
||||||
|
function opalestate_get_allowed_roles() {
|
||||||
|
return apply_filters( 'opalestate_get_allowed_roles', [
|
||||||
|
'opalestate_agent',
|
||||||
|
'opalestate_agency',
|
||||||
|
'opalestate_manager',
|
||||||
|
'administrator',
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
43
inc/vendors/opalmembership/membership.php
vendored
43
inc/vendors/opalmembership/membership.php
vendored
@ -290,26 +290,33 @@ class OpalEstate_Membership {
|
|||||||
public static function membership_menu( $menu ) {
|
public static function membership_menu( $menu ) {
|
||||||
if ( function_exists( "opalmembership_get_dashdoard_page_uri" ) ) {
|
if ( function_exists( "opalmembership_get_dashdoard_page_uri" ) ) {
|
||||||
global $opalmembership_options;
|
global $opalmembership_options;
|
||||||
$menu['membership'] = [
|
|
||||||
'icon' => 'fa fa-user',
|
|
||||||
'link' => opalmembership_get_dashdoard_page_uri(),
|
|
||||||
'title' => esc_html__( 'My Membership', 'opalestate-pro' ),
|
|
||||||
'id' => isset( $opalmembership_options['dashboard_page'] ) ? $opalmembership_options['dashboard_page'] : 0,
|
|
||||||
];
|
|
||||||
|
|
||||||
$menu['membership_history'] = [
|
if ( opalestate_current_user_can_access_dashboard_page( 'membership' ) ) {
|
||||||
'icon' => 'fa fa-user',
|
$menu['membership'] = [
|
||||||
'link' => opalmembership_get_payment_history_page_uri(),
|
'icon' => 'fa fa-user',
|
||||||
'title' => esc_html__( 'My Invoices', 'opalestate-pro' ),
|
'link' => opalmembership_get_dashdoard_page_uri(),
|
||||||
'id' => isset( $opalmembership_options['dashboard_page'] ) ? $opalmembership_options['dashboard_page'] : 0,
|
'title' => esc_html__( 'My Membership', 'opalestate-pro' ),
|
||||||
];
|
'id' => isset( $opalmembership_options['dashboard_page'] ) ? $opalmembership_options['dashboard_page'] : 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$menu['packages'] = [
|
if ( opalestate_current_user_can_access_dashboard_page( 'membership_history' ) ) {
|
||||||
'icon' => 'fa fa-certificate',
|
$menu['membership_history'] = [
|
||||||
'link' => opalmembership_get_membership_page_uri(),
|
'icon' => 'fa fa-user',
|
||||||
'title' => esc_html__( 'Renew membership', 'opalestate-pro' ),
|
'link' => opalmembership_get_payment_history_page_uri(),
|
||||||
'id' => isset( $opalmembership_options['dashboard_page'] ) ? $opalmembership_options['dashboard_page'] : 0,
|
'title' => esc_html__( 'My Invoices', 'opalestate-pro' ),
|
||||||
];
|
'id' => isset( $opalmembership_options['dashboard_page'] ) ? $opalmembership_options['dashboard_page'] : 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( opalestate_current_user_can_access_dashboard_page( 'packages' ) ) {
|
||||||
|
$menu['packages'] = [
|
||||||
|
'icon' => 'fa fa-certificate',
|
||||||
|
'link' => opalmembership_get_membership_page_uri(),
|
||||||
|
'title' => esc_html__( 'Renew membership', 'opalestate-pro' ),
|
||||||
|
'id' => isset( $opalmembership_options['dashboard_page'] ) ? $opalmembership_options['dashboard_page'] : 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $menu;
|
return $menu;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: Opal Estate Pro
|
* Plugin Name: Opal Estate Pro
|
||||||
* Plugin URI: https://wpdocs.gitbook.io/opal-estate/
|
* Plugin URI: https://wpdocs.gitbook.io/opal-estate/
|
||||||
* Description: Opal Real Estate Plugin is an ideal solution and brilliant choice for you to set up a professional estate website.
|
* Description: Opal Real Estate Plugin is an ideal solution and brilliant choice for you to set up a professional estate website.
|
||||||
* Version: 1.3.5
|
* Version: 1.3.6
|
||||||
* Author: WPOPAL
|
* Author: WPOPAL
|
||||||
* Author URI: http://www.wpopal.com
|
* Author URI: http://www.wpopal.com
|
||||||
* Requires at least: 4.9
|
* Requires at least: 4.9
|
||||||
@ -150,7 +150,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
|
|||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone() {
|
||||||
// Cloning instances of the class is forbidden
|
// Cloning instances of the class is forbidden
|
||||||
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.3.5' );
|
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.3.6' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,7 +159,7 @@ if ( ! class_exists( 'OpalEstate' ) ) {
|
|||||||
public function setup_constants() {
|
public function setup_constants() {
|
||||||
// Plugin version
|
// Plugin version
|
||||||
if ( ! defined( 'OPALESTATE_VERSION' ) ) {
|
if ( ! defined( 'OPALESTATE_VERSION' ) ) {
|
||||||
define( 'OPALESTATE_VERSION', '1.3.5' );
|
define( 'OPALESTATE_VERSION', '1.3.6' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin Folder Path
|
// Plugin Folder Path
|
||||||
|
@ -4,7 +4,7 @@ Donate link: https://wpdocs.gitbook.io/opal-estate/
|
|||||||
Tags: estate, property, opalestate, house for rent, agency for lease, estate submission, agents estate property, property marketplace
|
Tags: estate, property, opalestate, house for rent, agency for lease, estate submission, agents estate property, property marketplace
|
||||||
Requires at least: 4.9
|
Requires at least: 4.9
|
||||||
Tested up to: 5.3.2
|
Tested up to: 5.3.2
|
||||||
Stable tag: 1.3.5
|
Stable tag: 1.3.6
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
@ -156,6 +156,9 @@ This section describes how to install the plugin and get it working.
|
|||||||
* System tickets support 24/7 available : [free support](https://wpopal.ticksy.com/ "Visit the Plugin support Page")
|
* System tickets support 24/7 available : [free support](https://wpopal.ticksy.com/ "Visit the Plugin support Page")
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
= 1.3.6 - 2020-02-29 =
|
||||||
|
* Fixes - User register form & User roles
|
||||||
|
|
||||||
= 1.3.5 - 2020-02-28 =
|
= 1.3.5 - 2020-02-28 =
|
||||||
* Added - Time format setting
|
* Added - Time format setting
|
||||||
* Added - Hide unset amenities settings
|
* Added - Hide unset amenities settings
|
||||||
|
4
templates/user/error.php
Normal file
4
templates/user/error.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<div class="opalestate-user-dashboard-error">
|
||||||
|
<h4><?php esc_html_e( 'You need a higher level of permission or this page is denied with your user role.', 'opalestate-pro' ) ?></h4>
|
||||||
|
<p><?php esc_html_e( 'Sorry, you are not allowed to this page.', 'opalestate-pro' ); ?></p>
|
||||||
|
</div>
|
@ -25,6 +25,7 @@ if ( is_user_logged_in() ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$types = OpalEstate_User::get_user_types();
|
$types = OpalEstate_User::get_user_types();
|
||||||
|
$type_default = apply_filters( 'opalestate_register_form_default_type', 'subscriber' );
|
||||||
?>
|
?>
|
||||||
<div class="opalesate-form">
|
<div class="opalesate-form">
|
||||||
<?php if ( $hide_title === false ) : ?>
|
<?php if ( $hide_title === false ) : ?>
|
||||||
@ -69,7 +70,7 @@ $types = OpalEstate_User::get_user_types();
|
|||||||
<label for="userrole"><?php esc_html_e( 'Type', 'opalestate-pro' ); ?> <span class="required">*</span></label>
|
<label for="userrole"><?php esc_html_e( 'Type', 'opalestate-pro' ); ?> <span class="required">*</span></label>
|
||||||
<select name="role" id="userrole" class="form-control">
|
<select name="role" id="userrole" class="form-control">
|
||||||
<?php foreach ( $types as $type => $label ): ?>
|
<?php foreach ( $types as $type => $label ): ?>
|
||||||
<option value="<?php echo $type; ?>"><?php echo $label; ?></option>
|
<option value="<?php echo $type; ?>" <?php selected( $type, $type_default, true ); ?>><?php echo $label; ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user