Function Reference: geodir_claim_template_loader

Summary

This function has not been documented yet.

Filters

‘geodir_template_information’ [Line: 372]

Source Code

function geodir_claim_template_loader( $template ){

	global $wp_query, $current_user, $plugin_prefix, $wpdb;
	
	if(isset($_REQUEST['geodir_ptype'])){
		
		global $information;
		
		if($current_user->ID){
			
			if(get_option('geodir_claim_auto_approve')=='yes'){
				
				if(!isset($_REQUEST['rs']) || (isset($_REQUEST['rs']) && $_REQUEST['rs']=='')){
					
					$information .= CLAIM_VARIFY_CODE_NOT_EXIST;
					
				}else{
						
					$rand_string = isset($_REQUEST['rs']) ? $_REQUEST['rs'] : '';	
					
					$approvesql = $wpdb->prepare("select * from ".GEODIR_CLAIM_TABLE." where rand_string=%s",array($rand_string));
					
					$approveinfo = $wpdb->get_results($approvesql);
					
					if($approveinfo)
					{
						$pid = $approveinfo[0]->pid;
						
						$post_id = $approveinfo[0]->list_id;
						
						$author_id = $approveinfo[0]->user_id;
						
						$user_id = $current_user->ID;
						
						$status = $approveinfo[0]->status;
						
						if($author_id==$user_id)
						{
							
							if($status==1)
							{
								$information .= CLAIM_LISTING_ALREADY_VARIFIED;
							}
							elseif($status==2)
							{
								$information .= CLAIM_LISTING_VERIFICATION_REJECTED;
							}
							else
							{
								
								$wpdb->query($wpdb->prepare("update $wpdb->posts set post_author=%d where ID=%d", array($author_id,$post_id))); 
								
								$wpdb->query($wpdb->prepare("update ".GEODIR_CLAIM_TABLE." set status='1' where pid=%d", array($pid)));
								
								geodir_save_post_meta($post_id, 'claimed','1');
																
								/** This action is documented in geodir_claim_functions.php */
								do_action('geodir_claim_request_status_change', $pid, 1, $status);
								
								geodir_clientEmail($post_id,$author_id,'claim_approved'); /* email to client */
								
								$information .= CLAIM_LISTING_SUCCESS_VERIFIED.' '.$approveinfo[0]->list_title.'';		
								
							}	
						}
						else
						{
							$information .= CLAIM_VARIFY_CODE_NOT_MATCH;
						}
					}
					else
					{
						$information .= CLAIM_VARIFY_CODE_NOT_EXIST;
					}	
				}
			
			}else{
				$information .= CLAIM_AUTO_VARIFY_DISABLE;
			}
			
		}else{
            $site_login_url = geodir_login_url();

            $information .= sprintf( CLAIM_LOGIN_REQUIRED, '');
		}
		
		$template = geodir_locate_template('information');
		
		if ( ! $template ) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php';
		
		$template = apply_filters('geodir_template_information',$template);
		
	}
	
	return $template;	
}