Alex Howes

Forum Replies Created

Viewing 15 posts - 76 through 90 (of 131 total)
  • Author
    Posts
  • in reply to: Geodirectory linked listings #430217

    Alex Howes
    Expired Member
    Post count: 175

    Sorry. My site is primarily a farm job site. There are two CPTs, jobs and farms, which are linked. Users with the role “employer” can claim farm listings, list farms, and post jobs.

    Currently employers can post jobs whether or not they have a farm because the “Link Farm” option at the top of the add job form is optional.

    However, I want to force all employers to link posted jobs to one of their farms, and not be able to post jobs if they don’t have a farm. I.e. there should be no jobs appearing that aren’t linked to a farm. Is it possible to do this?

    in reply to: Listing slider not working #430207

    Alex Howes
    Expired Member
    Post count: 175

    I tested it with a listing that did have a featured image, and it’s working fine. Sorry for the trouble.

    in reply to: Listing slider not working #430206

    Alex Howes
    Expired Member
    Post count: 175

    Ah, ok, thanks 🙂

    in reply to: Listing slider not working #430203

    Alex Howes
    Expired Member
    Post count: 175

    Sorry, I didn’t realise that. The listing has a default image- can that not be used?

    Alex

    in reply to: Listing slider not working #430175

    Alex Howes
    Expired Member
    Post count: 175
    This reply has been marked as private.
    in reply to: Disable/ remove links to category listing page #429967

    Alex Howes
    Expired Member
    Post count: 175

    Thanks Kor, that’s perfect! I’ll apply it in the same way to my other pages 🙂

    in reply to: Disable/ remove links to category listing page #429960

    Alex Howes
    Expired Member
    Post count: 175

    Thanks Kor, I didn’t realise custom CSS could be used to do that 🙂

    An example page is this: https://www.barn-door.co.uk/farms/coybal-farm/ where the category link is “Dairy Cows” at the top of the page.

    in reply to: Restrict page access #429941

    Alex Howes
    Expired Member
    Post count: 175

    Sorry for the last question, I’ve got it working now 🙂 In case anyone else is interested in doing this I’ve posted my code below. Thanks for your help! 🙂

    The post type (CPT) I’m blocking is “gd_cv”, which I’m only allowing the logged in listing owner to view.

    
    
    function cv_detail_redirect()
        {
        $current_user = wp_get_current_user();
        $current_user_roles = $current_user->roles;
        global $post;
      
        if ($post) {
      
        $author_id = $post->post_author;
      
        if( geodir_is_page('detail') && ! is_user_logged_in() && geodir_get_current_posttype() == 'gd_cv')
        {
            wp_redirect( home_url( '/login/' ) );
            die;
        }
        elseif( geodir_is_page('detail') && is_user_logged_in() && geodir_get_current_posttype() == 'gd_cv')
        {
    	    if ( ! ( current_user_can('manage_options') || ( !empty( $author_id ) && get_current_user_id() == $author_id ) ) ) {
    		
            	wp_redirect( home_url( '' ) );
        	    die;
      }
        }
    	}
    }
    add_action( 'template_redirect', 'cv_detail_redirect' );
    in reply to: Restrict page access #429924

    Alex Howes
    Expired Member
    Post count: 175

    Thanks! I’ve almost got it working. Is there a GD function to get the id of the listing owner?

    in reply to: Restrict page access #429900

    Alex Howes
    Expired Member
    Post count: 175

    Yes I understand that bit but is there a way to check if the current page is a geodirectory listing detail page without specifying the url?

    in reply to: Restrict page access #429888

    Alex Howes
    Expired Member
    Post count: 175

    Thanks for the suggestion but I’m not sure that would work since I can’t specify a specific url to redirect from. I rather want it to redirect on every listing detail page and since I have lots of them (and they’re created by users) I can’t specify each one.

    in reply to: Restrict page access #429756

    Alex Howes
    Expired Member
    Post count: 175

    Thanks Alex

    I’m using the following code (found here https://userswp.io/support/topic/restrict-users-from-seeing-each-others-profiles/) to restrict access to only allow users to view their own profile.

    
    
    function _uwp_custom_profile_access( $access, $user ) {
        if ( ! ( current_user_can('manage_options') || ( !empty( $user ) && get_current_user_id() == $user->ID ) ) ) {
            $access = false;
        }
    
        return $access;
    }
    add_filter( 'uwp_profile_access', '_uwp_custom_profile_access', 10, 2 );
    
    function _uwp_custom_profile_access_denied( $user ) {
        ?>
        <div><p><?php echo __( 'You are not allowed to view this profile!' ); ?></p></div>
        <?php
    }
    add_action( 'uwp_profile_access_denied', '_uwp_custom_profile_access_denied', 10, 1 );

    I was wondering if there are hooks equivalent to _uwp_profile_access and _uwp_profile_access_denied that I can use to restrict listing pages in a similar way?

    in reply to: Limit listings of certain CPTs to 1 per user #429497

    Alex Howes
    Expired Member
    Post count: 175

    Hi Kiran, I’ve just got it to work using this:

    
    
    add_action('geodir_after_save_listing', 'change_user_role_when_submit_cv');
    
    function change_user_role_when_submit_cv( $last_post_id, $request_info ) {
      
      if (geodir_get_current_posttype() == 'gd_cv') {
    	
    	$current_user = wp_get_current_user();
    	$current_user_roles = $current_user->roles;
    	
    	if (in_array('um_worker', $current_user_roles)){
    	  
    	  	$current_user->set_role( 'worker_has_cv' );
    	}
      
      }
    }

    Thanks for your help with this 🙂

    in reply to: Limit listings of certain CPTs to 1 per user #429495

    Alex Howes
    Expired Member
    Post count: 175

    Hi Dirk, yes, the post_type is ‘gd_cv’. You can see it in the JSON file here under “type” http://www.barn-door.co.uk/wp-json/geodir/v1/cvs.

    in reply to: Limit listings of certain CPTs to 1 per user #429489

    Alex Howes
    Expired Member
    Post count: 175

    Thanks Dirk, I’ve changed it to that and it’s still not working. If I remove the if statement completely it works, so it must be a problem with getting the post type.

Viewing 15 posts - 76 through 90 (of 131 total)
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount