Ejemplo n.º 1
0
function um_dynamic_user_profile_title($title, $id = '')
{
    global $ultimatemember;
    if (is_admin()) {
        return $title;
    }
    if ($id == $ultimatemember->permalinks->core['user']) {
        if (um_is_core_page('user') && um_get_requested_user()) {
            $title = um_get_display_name(um_get_requested_user());
        } else {
            if (um_is_core_page('user') && is_user_logged_in()) {
                $title = um_get_display_name(get_current_user_id());
            }
        }
    }
    return strlen($title) !== strlen(utf8_decode($title)) ? $title : utf8_encode($title);
}
 /**
  * Fetches title from special fields, like other plugins with special queries.
  * Used before and has priority over custom fields.
  * Front end only.
  *
  * @since 2.5.2
  *
  * @return string $title Title from Special Field.
  */
 public function title_from_special_fields()
 {
     $title = '';
     if (false === $this->is_admin()) {
         if ($this->is_ultimate_member_user_page() && um_is_core_page('user') && um_get_requested_user()) {
             $title = um_user('display_name');
         }
     }
     return $title;
 }
Ejemplo n.º 3
0
function um_is_myprofile()
{
    global $ultimatemember;
    if (get_current_user_id() && get_current_user_id() == um_get_requested_user()) {
        return true;
    }
    if (!um_get_requested_user() && um_is_core_page('user') && get_current_user_id()) {
        return true;
    }
    return false;
}
Ejemplo n.º 4
0
 function load($args)
 {
     global $ultimatemember;
     ob_start();
     $defaults = array();
     $args = wp_parse_args($args, $defaults);
     // when to not continue
     $this->form_id = isset($args['form_id']) ? $args['form_id'] : null;
     if (!$this->form_id) {
         return;
     }
     $this->form_status = get_post_status($this->form_id);
     if ($this->form_status != 'publish') {
         return;
     }
     // get data into one global array
     $post_data = $ultimatemember->query->post_data($this->form_id);
     $args = apply_filters('um_pre_args_setup', $post_data);
     if (!isset($args['template'])) {
         $args['template'] = '';
     }
     if (isset($post_data['template']) && $post_data['template'] != $args['template']) {
         $args['template'] = $post_data['template'];
     }
     if (!$this->template_exists($args['template'])) {
         $args['template'] = $post_data['mode'];
     }
     if (!isset($post_data['template'])) {
         $post_data['template'] = $post_data['mode'];
     }
     $args = array_merge($post_data, $args);
     if (isset($args['use_globals']) && $args['use_globals'] == 1) {
         $args = array_merge($args, $this->get_css_args($args));
     } else {
         $args = array_merge($this->get_css_args($args), $args);
     }
     // filter for arguments
     $args = apply_filters('um_shortcode_args_filter', $args);
     extract($args, EXTR_SKIP);
     // for profiles only
     if ($mode == 'profile' && um_profile_id() && isset($args['role']) && $args['role'] && $args['role'] != $ultimatemember->query->get_role_by_userid(um_profile_id())) {
         return;
     }
     // start loading the template here
     do_action("um_pre_{$mode}_shortcode", $args);
     do_action("um_before_form_is_loaded", $args);
     do_action("um_before_{$mode}_form_is_loaded", $args);
     $this->template_load($template, $args);
     $this->dynamic_css($args);
     if (um_get_requested_user() || $mode == 'logout') {
         um_reset_user();
     }
     do_action('um_after_everything_output');
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
function um_pre_profile_shortcode($args)
{
    global $ultimatemember;
    extract($args);
    if ($mode == 'profile' && $ultimatemember->fields->editing == false) {
        $ultimatemember->fields->viewing = 1;
        if (um_get_requested_user()) {
            if (!um_can_view_profile(um_get_requested_user())) {
                um_redirect_home();
            }
            if (!um_current_user_can('edit', um_get_requested_user())) {
                $ultimatemember->user->cannot_edit = 1;
            }
            um_fetch_user(um_get_requested_user());
        } else {
            if (!is_user_logged_in()) {
                um_redirect_home();
            }
            if (!um_user('can_edit_profile')) {
                $ultimatemember->user->cannot_edit = 1;
            }
        }
    }
    if ($mode == 'profile' && $ultimatemember->fields->editing == true) {
        $ultimatemember->fields->editing = 1;
        if (um_get_requested_user()) {
            if (!um_current_user_can('edit', um_get_requested_user())) {
                um_redirect_home();
            }
            um_fetch_user(um_get_requested_user());
        }
    }
}