Update front end profile.

This commit is contained in:
Hoang Huu 2019-10-01 12:23:57 +07:00
parent c8c1739fb5
commit 7840e83f62
4 changed files with 80 additions and 78 deletions

View File

@ -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 {
@ -322,13 +321,13 @@ class Opalestate_Agency_Front {
$atts = is_array( $atts ) ? $atts : [];
$default = array(
$default = [
'current_uri' => null,
'column' => 3,
'limit' => 12,
'paged' => 1,
'onlyfeatured' => 0,
);
];
$atts = array_merge( $default, $atts );
@ -343,10 +342,10 @@ class Opalestate_Agency_Front {
$atts = is_array( $atts ) ? $atts : [];
$layout = 'search-agency-form';
$default = array(
$default = [
'current_uri' => null,
'form' => $layout
);
'form' => $layout,
];
$atts = array_merge( $default, $atts );
@ -357,12 +356,20 @@ class Opalestate_Agency_Front {
*
*/
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'] = '=';

View File

@ -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 );

View File

@ -1,4 +1,3 @@
<div class="property-submission-form">
<?php if ( ! empty( $_SESSION['messages'] ) ) : ?>
@ -12,7 +11,8 @@
<?php printf( '%s', $msg ) ?>
</div>
<?php endforeach; unset( $_SESSION['messages'] ); ?>
<?php endforeach;
unset( $_SESSION['messages'] ); ?>
</div>
<?php endif; ?>
@ -24,13 +24,12 @@
<?php
do_action( 'opalestate_profile_agency_form_before' );
// echo '<Pre>'.print_r( $metaboxes ,1 );die;
if ( function_exists( 'cmb2_get_metabox_form' ) ) {
echo cmb2_get_metabox_form( $metaboxes[OPALESTATE_AGENCY_PREFIX.'front'], $post_id, array(
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' );

View File

@ -1,4 +1,3 @@
<div class="property-submission-form">
<div class="opalestate-admin-box">
@ -8,7 +7,7 @@
<?php if ( isset( $metaboxes[ OPALESTATE_AGENT_PREFIX . 'front' ] ) ): ?>
<?php
do_action( 'opalestate_profile_agency_form_before' );
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, [