Update front end profile.
This commit is contained in:
parent
c8c1739fb5
commit
7840e83f62
@ -61,9 +61,9 @@ class Opalestate_Agency_Front {
|
||||
|
||||
add_filter( 'opalestate_management_user_menu', [ $this, 'render_extra_profile_link' ] );
|
||||
|
||||
add_action( "opalestate_user_content_agency_profile_page", [ $this, 'render_profile' ] );
|
||||
add_action( "opalestate_user_content_agency_team_page", [ $this, 'render_team' ] );
|
||||
add_action( "opalestate_user_init", [ $this, 'process_action_member' ] );
|
||||
add_action( 'opalestate_user_content_agency_profile_page', [ $this, 'render_profile' ] );
|
||||
add_action( 'opalestate_user_content_agency_team_page', [ $this, 'render_team' ] );
|
||||
add_action( 'opalestate_user_init', [ $this, 'process_action_member' ] );
|
||||
|
||||
$this->register_shortcodes();
|
||||
}
|
||||
@ -153,7 +153,6 @@ class Opalestate_Agency_Front {
|
||||
unset( $_POST[ $prefix . 'title' ] );
|
||||
unset( $_POST[ $prefix . 'text' ] );
|
||||
|
||||
|
||||
if ( $data['ID'] > 0 ) {
|
||||
$post_id = wp_update_post( $data, true );
|
||||
} else {
|
||||
@ -309,8 +308,8 @@ class Opalestate_Agency_Front {
|
||||
*/
|
||||
public function register_shortcodes() {
|
||||
$this->shortcodes = [
|
||||
'search_agencies' => [ 'code' => 'search_agencies', 'label' => esc_html__( 'Search Agencies', 'opalestate-pro' ) ],
|
||||
'agency_carousel' => [ 'code' => 'agency_carousel', 'label' => esc_html__( 'Agency Carousel', 'opalestate-pro' ) ],
|
||||
'search_agencies' => [ 'code' => 'search_agencies', 'label' => esc_html__( 'Search Agencies', 'opalestate-pro' ) ],
|
||||
'agency_carousel' => [ 'code' => 'agency_carousel', 'label' => esc_html__( 'Agency Carousel', 'opalestate-pro' ) ],
|
||||
];
|
||||
|
||||
foreach ( $this->shortcodes as $shortcode ) {
|
||||
@ -318,51 +317,59 @@ class Opalestate_Agency_Front {
|
||||
}
|
||||
}
|
||||
|
||||
public function agency_carousel ( $atts ) {
|
||||
public function agency_carousel( $atts ) {
|
||||
|
||||
$atts = is_array( $atts ) ? $atts : [];
|
||||
|
||||
$default = [
|
||||
'current_uri' => null,
|
||||
'column' => 3,
|
||||
'limit' => 12,
|
||||
'paged' => 1,
|
||||
'onlyfeatured' => 0,
|
||||
];
|
||||
|
||||
$atts = is_array( $atts ) ? $atts : [];
|
||||
|
||||
$default = array(
|
||||
'current_uri' => null,
|
||||
'column' => 3,
|
||||
'limit' => 12,
|
||||
'paged' => 1,
|
||||
'onlyfeatured' => 0,
|
||||
);
|
||||
|
||||
$atts = array_merge( $default, $atts );
|
||||
|
||||
return opalestate_load_template_path( 'shortcodes/agency-carousel' , $atts );
|
||||
}
|
||||
return opalestate_load_template_path( 'shortcodes/agency-carousel', $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function search_agencies ( $atts=[] ) {
|
||||
|
||||
$atts = is_array( $atts ) ? $atts : [];
|
||||
$layout = 'search-agency-form';
|
||||
public function search_agencies( $atts = [] ) {
|
||||
|
||||
$atts = is_array( $atts ) ? $atts : [];
|
||||
$layout = 'search-agency-form';
|
||||
|
||||
$default = [
|
||||
'current_uri' => null,
|
||||
'form' => $layout,
|
||||
];
|
||||
|
||||
$default = array(
|
||||
'current_uri' => null,
|
||||
'form' => $layout
|
||||
);
|
||||
|
||||
$atts = array_merge( $default, $atts );
|
||||
|
||||
return opalestate_load_template_path( 'shortcodes/search-agencies' , $atts );
|
||||
return opalestate_load_template_path( 'shortcodes/search-agencies', $atts );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render_profile() {
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$post_id = OpalEstate_User::get_member_id();
|
||||
|
||||
if ( isset( $post->ID ) && $post->post_status != 'publish' ) {
|
||||
opalestate_add_notice( "warning", esc_html__( 'You account is under reviewing! it take some time to process' ) );
|
||||
add_action( "opalestate_profile_agency_form_before", "opalestate_print_notices" );
|
||||
// Check if have not any relationship, create a new then update this meta value.
|
||||
if ( ! $post_id || $post_id < 0 ) {
|
||||
static::on_set_role( $user_id );
|
||||
}
|
||||
|
||||
$post_id = get_user_meta( $user_id, OPALESTATE_USER_PROFILE_PREFIX . 'related_id', true );
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( isset( $post->ID ) && ( $post->post_status != 'publish' || $post->ID == get_the_ID() ) ) {
|
||||
opalestate_add_notice( 'warning', esc_html__( 'You account is under reviewing! It take some time to process.', 'opalestate-pro' ) );
|
||||
add_action( 'opalestate_profile_agency_form_before', 'opalestate_print_notices' );
|
||||
}
|
||||
|
||||
$metaboxes = $this->render_front_form( [], $post_id );
|
||||
@ -446,15 +453,12 @@ class Opalestate_Agency_Front {
|
||||
}
|
||||
|
||||
public static function on_set_role( $user_id ) {
|
||||
|
||||
if ( $user_id ) {
|
||||
|
||||
$args = [
|
||||
'post_type' => 'opalestate_agency',
|
||||
'posts_per_page' => 10,
|
||||
];
|
||||
|
||||
|
||||
$args['meta_key'] = OPALESTATE_AGENCY_PREFIX . 'user_id';
|
||||
$args['meta_value'] = $user_id;
|
||||
$args['meta_compare'] = '=';
|
||||
|
@ -103,7 +103,7 @@ class Opalestate_Agent_Front {
|
||||
|
||||
if ( isset( $post->ID ) && ( $post->post_status != 'publish' || $post->ID == get_the_ID() ) ) {
|
||||
opalestate_add_notice( 'warning', esc_html__( 'You account is under reviewing! It take some time to process.', 'opalestate-pro' ) );
|
||||
add_action( 'opalestate_profile_agency_form_before', 'opalestate_print_notices' );
|
||||
add_action( 'opalestate_profile_agent_form_before', 'opalestate_print_notices' );
|
||||
}
|
||||
|
||||
$metaboxes = $this->render_front_form( [], $post_id );
|
||||
|
@ -1,40 +1,39 @@
|
||||
|
||||
<div class="property-submission-form">
|
||||
|
||||
<?php if ( ! empty( $_SESSION['messages'] ) ) : ?>
|
||||
|
||||
<div class="opalesate_messages">
|
||||
<div class="opalesate_messages">
|
||||
<?php foreach ( $_SESSION['messages'] as $message ) : ?>
|
||||
|
||||
<?php $status = isset( $message[0] ) ? $message[0] : 'success'; ?>
|
||||
<?php $msg = isset( $message[1] ) ? $message[1] : ''; ?>
|
||||
<div class="opalesate_message_line <?php echo esc_attr( $status ) ?>">
|
||||
<div class="opalesate_message_line <?php echo esc_attr( $status ) ?>">
|
||||
<?php printf( '%s', $msg ) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach; unset( $_SESSION['messages'] ); ?>
|
||||
</div>
|
||||
<?php endforeach;
|
||||
unset( $_SESSION['messages'] ); ?>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="opalestate-admin-box">
|
||||
|
||||
<div class="box-content">
|
||||
<h3><?php esc_html_e( 'Edit Agency Profile', 'opalestate-pro' ); ?></h3>
|
||||
<div class="opalestate-admin-box">
|
||||
|
||||
<div class="box-content">
|
||||
<h3><?php esc_html_e( 'Edit Agency Profile', 'opalestate-pro' ); ?></h3>
|
||||
|
||||
<?php
|
||||
do_action( 'opalestate_profile_agency_form_before' );
|
||||
// echo '<Pre>'.print_r( $metaboxes ,1 );die;
|
||||
do_action( 'opalestate_profile_agency_form_before' );
|
||||
|
||||
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
|
||||
echo cmb2_get_metabox_form( $metaboxes[OPALESTATE_AGENCY_PREFIX.'front'], $post_id, array(
|
||||
'form_format' => '<form action="//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '" class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%2$s">%3$s<button type="submit" name="submit-cmb" class="button-primary btn btn-primary">%4$s</button></form>',
|
||||
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
|
||||
) );
|
||||
}
|
||||
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
|
||||
echo cmb2_get_metabox_form( $metaboxes[ OPALESTATE_AGENCY_PREFIX . 'front' ], $post_id, [
|
||||
'form_format' => '<form action="//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '" class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%2$s">%3$s<button type="submit" name="submit-cmb" class="button-primary btn btn-primary">%4$s</button></form>',
|
||||
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
|
||||
] );
|
||||
}
|
||||
|
||||
do_action( 'opalestate_profile_agency_form_after' );
|
||||
do_action( 'opalestate_profile_agency_form_after' );
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,27 +1,26 @@
|
||||
|
||||
<div class="property-submission-form">
|
||||
|
||||
<div class="opalestate-admin-box">
|
||||
|
||||
<div class="box-content">
|
||||
<h3><?php esc_html_e( 'Edit Agent Profile', 'opalestate-pro' ); ?></h3>
|
||||
|
||||
<?php if( isset($metaboxes[OPALESTATE_AGENT_PREFIX.'front']) ): ?>
|
||||
<?php
|
||||
do_action( 'opalestate_profile_agency_form_before' );
|
||||
<div class="opalestate-admin-box">
|
||||
|
||||
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
|
||||
echo cmb2_get_metabox_form( $metaboxes[ OPALESTATE_AGENT_PREFIX . 'front' ], $post_id, [
|
||||
'form_format' => '<form action="//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '" class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%2$s">%3$s<button type="submit" name="submit-cmb" class="button-primary btn btn-primary">%4$s</button></form>',
|
||||
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
|
||||
] );
|
||||
}
|
||||
<div class="box-content">
|
||||
<h3><?php esc_html_e( 'Edit Agent Profile', 'opalestate-pro' ); ?></h3>
|
||||
|
||||
<?php if ( isset( $metaboxes[ OPALESTATE_AGENT_PREFIX . 'front' ] ) ): ?>
|
||||
<?php
|
||||
do_action( 'opalestate_profile_agent_form_before' );
|
||||
|
||||
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
|
||||
echo cmb2_get_metabox_form( $metaboxes[ OPALESTATE_AGENT_PREFIX . 'front' ], $post_id, [
|
||||
'form_format' => '<form action="//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '" class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%2$s">%3$s<button type="submit" name="submit-cmb" class="button-primary btn btn-primary">%4$s</button></form>',
|
||||
'save_button' => esc_html__( 'Save Change', 'opalestate-pro' ),
|
||||
] );
|
||||
}
|
||||
|
||||
do_action( 'opalestate_profile_agency_form_after' );
|
||||
?>
|
||||
?>
|
||||
<?php else : ?>
|
||||
<div class="alert alert-danger"><?php esc_html_e( 'Agent edit profile form is not avariable', 'opalestate-pro' ); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-danger"><?php esc_html_e( 'Agent edit profile form is not avariable', 'opalestate-pro' ); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user