Forum Replies Created

Viewing 15 replies - 1 through 15 (of 27 total)
  • Thread Starter hazratnoor

    (@hazratnoor)

    Hi Amanda!

    I have already an account on WooCommerce and have submitted a ticket over there, but because I am working on my client website and she (my client) herself purchased this plugin, so the support team on WooCommerce is not able to identify my email address matching to any account.

    In response, they have suggested me to use this forum for getting help. What if I use my client email address (the one she used for purchasing WooCommerce) in my question description. Is this going to make any sense for the support team?

    • This reply was modified 5 years, 4 months ago by hazratnoor.
    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    I sort out the problem using advanced-ads-ad-notices filter_hook. There was a problem with advanced-ads-ad-notices filter_hook which I already pointed out to you in my earlier reply and now I have resolved that using transient.

    Because, approximately 7 admin notices were appearing when I used the above filter_hook, so I removed/deleted all admin notices except one. My code is listed here and is working fine for me:

    function published_ads_limit( $ID, $post ) {
        $max_posts = 1;
    	
    	$advertiser_user = '';
    	$author = '';
    	if(is_current_user_advertiser()){
    		$author = $post->post_author;
    	}
    	else{
    		return;
    	}
        
    	$count = count_user_posts( $author, 'advanced_ads'); // get author post count
        if ( $count > $max_posts ) {
    		$post->post_status = 'draft';
            wp_update_post( $post);
    		
    		$user_id = get_current_user_id();
    		
    		set_transient( get_current_user_id().'adslimiterror', "Your current advertising package does not allow adding more than one ad!" );
        }
    }
    add_action( 'publish_advanced_ads', 'published_ads_limit', 99, 2 );
    
    function limit_published_advanced_ads( $ID, $post ) {
        global $pagenow;
    	if (( $pagenow == 'post.php' ) && 'advanced_ads' == get_post_type( $_GET['post'] ) && isset($_GET['post'])) {
    		if($out = get_transient( get_current_user_id().'adslimiterror' ) ) {
    			delete_transient( get_current_user_id().'adslimiterror' );
    			echo '<div class="error notice is-dismissible" style="background-color: #ffc9c9;"><p>'.$out.'</p></div>';
    		}
    	}
    }
    add_filter( 'advanced-ads-ad-notices', 'limit_published_advanced_ads', 99, 2 );

    I am marking this reply as resolved.

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    No worries. I tried myself with a few advanced ads filter-hooks like advanced-ads-notices & advanced-ads-ad-notices. Unfortunately, the advanced-ads-notices filter-hook doesn’t do anything. However, advanced-ads-ad-notices filter-hook output all of the notices (7 for meta boxes on the ad edit screen).

    My actual problem is already resolved (not to allow the advertiser users to publish more than one ad), however, I was further looking for notifying him/her (which doesn’t seem to be possible) that the ad is saved as drafts and that he/she cannot publish another ad.

    Thanks for the detailed support you provided again.

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    You got my point. When an advertiser will try to publish a new ad or click on the publish button on an existing ad, then I want to show the admin notice that he cannot publish more than one ad and his/her ad is saved as drafts.

    The code is already done for saving the ad as drafts. Only need assistance in adding the admin notice before or after wp_update_post( $post);.

    Thanks,
    Usman

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    There is nothing change in both these questions. I am sorry for that but I was having two reasons in my mind while reposting the question:

    1. To get your instant attention.
    2. To provide the code in a bit more managed order (because the code indentation in my first question was not looking good).

    Thanks
    Usman

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    Yes, based on using specific JavaScript & CSS files (which loads only if an Advertiser User is logged-in). These files (CSS & JS) are enqueued in my functions.php based on user role i.e. if Advertiser user is logged in, then load these files. The JS file simply contain the following lines of code:

    jQuery(document).ready(function(){
        if(!$('#advads-stop-wizard').hasClass('hidden')){
    		$('#advads-stop-wizard').trigger('click');
    	}
    });

    As soon as a user will try to create a new ad, this code will not allow the Wizard to start. So the user will simply put the title, add description/image and hit the publish button on the right side.

    Also, I have hide sections which were not required for advertiser user i.e. display conditions etc…

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    The JS Code works for me.

    I simply added the following code to a custom .js file and enqueued this file in my functions.php.

    jQuery(document).ready(function(){
        if(!$('#advads-stop-wizard').hasClass('hidden')){
    		$('#advads-stop-wizard').trigger('click');
    	}
    });

    After adding the code, I refresh the page and then click on the “Create Ad” button. The JS code triggered the Stop Wizard button and this was what I was looking for. Later, I added targeted CSS code (for advertiser users only) and hide those sections including the Stop/Start Wizard button and hide them. Now, Advertiser users just create a new ad and cannot change anything else.

    Also, I would like to appreciate your contribution in creating such a great plugin.

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    That’s exactly what I need. If applicable in-fact, there needs to be some way for allowing admin to hide/show sections/components based on user role.

    In my case, I was thinking about JavaScript and CSS as my only solution in-case I would not hear from you back. So I would like to confirm that is JavaScript code smart enough to bypass the plugin’s default feature (disable the wizard)? If yes, then how will I specify in my JS code that you (the Wizard) must stay hidden. I think JS may handle this using the wizard id?

    Thread Starter hazratnoor

    (@hazratnoor)

    My problem is resolved now. The above solution can be used to show those mentioned fields including business brand, company website, job location, company name and company tagline as prefilled for an existing user. If the user has already posted a job in the past, these fields will be shown prefilled.

    Thread Starter hazratnoor

    (@hazratnoor)

    The following solution works for me:

    function save_job_meta( $post_id, $post, $update ) {
    
        $post_type = get_post_type($post_id);
        $meta = get_post_meta( $post_id );
    	//var_dump( $post );
        // If this isn't a 'job_listing' post, don't update it.
        if ( "job_listing" != $post_type ) return;
            
    	$location = $meta['_job_location'][0];
    	$brand = $meta['_business_brand'][0];
        
        if($update){    
    	    update_user_meta( get_current_user_id(), '_job_location', $meta['_job_location'][0] );
    	    update_user_meta( get_current_user_id(), '_business_brand', $meta['_business_brand'][0] );
    	    update_user_meta( get_current_user_id(), '_company_website', $meta['_company_website'][0] );
    	    update_user_meta( get_current_user_id(), '_company_name', $meta['_company_name'][0] );
    	    update_user_meta( get_current_user_id(), '_company_tagline', $meta['_company_tagline'][0] );
    	}
    }
    add_action( 'save_post', 'save_job_meta', 10, 3 );
    Thread Starter hazratnoor

    (@hazratnoor)

    I have tried the following snippet at the end of my theme’s functions.php file and it doesn’t change anything in the admin side.

    add_filter('submit_job_form_fields', 'bk_prefill_jobs_location');
    	function bk_prefill_jobs_location( $fields ) {
    	  $fields['job']['job_location']['value'] = 'My Custom City Name';
    	  return $fields;
    	}

    Under the Job Listings sidebar item (which appears after installing WP Job Manager Plugin), when a user will click on the Add New sub-menu item for adding a new job, I want this code snippet to prefill the location field for the user. Is this possible with this snippet or am I misunderstanding the purpose of customization through code snippets?

    Thread Starter hazratnoor

    (@hazratnoor)

    The prefill snippets will be going directly to my theme’s functions.php? Or into another file?

    Thread Starter hazratnoor

    (@hazratnoor)

    https://rchto.staging.wpengine.com/sponsor-spotlight/

    It shows the exact ad URL when I hover on the ad title. Upon clicking on the ad, the same URL (the exact ad URL) still appear in the browser but after a while, when the page finishes loading, redirection to the home page occurs.

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    I have got some problem with advanced ads (showing a single advanced ad). As per my requirements, I have created a template file where I can show all the ads. Now when I click on the ad title (which has an anchor tag holding the actual ad URL – For each ad), I am redirected to the home page, every time. Is there any technical reason for the said issue? Because everything else is working fine and even I have created several other template files for other custom post types and they all work fine.

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    I have got my solution with the help of your last reply. You may mark this activity as resolved. Thanks for your kind support.

    Regards,
    HazratNoor

Viewing 15 replies - 1 through 15 (of 27 total)