Auto assign listings to admin

This topic contains 8 replies, has 5 voices, and was last updated by  evocativemedia 5 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #504713

    evocativemedia
    Expired Member
    Post count: 28

    Hi,

    I use geodirectory with buddypress, and I would like that when users submit a listing, it is automatically assigned to the admin.

    I saw a topic from 2018:

    https://wpgeodirectory.com/support/topic/auto-assign-author-of-listing/

    which concerns exactly the same functionality for which you guys provided a snippet. However, I’ve tried this snippet and it doesn’t work anymore. Is it possible for you to help me out or point me in the right direction?

    #504724

    Guust
    Moderator
    Post count: 29970

    I’ll get a developer to have a look at your question after the weekend.
    Thanks

    #504741

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Things work a bit different now so that old snippet likely wont work. The issue is that the post is saved several times, on the add listing page and then when submitted, and if a paid listing then it needs to belong to the user so the invoice is generated correctly and can be paid.

    I don’t know your reasoning for this but knowing might help suggest a solution.

    You could always set any GD listings to the admin ID on the post publish action, that might be a easy solution that would work for you?

    Thanks,

    Stiofan

    #505113

    evocativemedia
    Expired Member
    Post count: 28

    Yes that suggestion would work. I am working on a community in which each member can add and edit places (I changed user role capabilities to let a certain role be able to edit other’s posts), so that information can stay up to date. When they add a listing, it should be assigned to the admin so that no one actually ‘owns’ a listing.

    So for ‘gd_places’, I can use the post publish action? Where can I find documentation on this or where can I find this action?

    Thanks Stiofan!

    #505670

    evocativemedia
    Expired Member
    Post count: 28

    I don’t want to be impatient, but any idea?

    #505790

    Alex Rollin
    Moderator
    Post count: 27815

    The developers will reply as soon as possible.

    Thanks for your patience

    Alex

    #508566

    evocativemedia
    Expired Member
    Post count: 28

    I know you guys are very busy, but I was wondering whether any progress has been made on this topic.

    #508867

    Kiran
    Moderator
    Post count: 7069

    Hi,

    Please try following PHP snippet.

    
    
    /**
     * Set author to GD listing.
     */
    function gd_snippet_190918_wp_insert_post_data( $data, $postarr ) {
    	if ( ! empty( $data['post_type'] ) && $data['post_type'] != 'revision' && ! geodir_is_gd_post_type( $data['post_type'] ) ) {
    		return $data;
    	}
    
    	if ( ! empty( $data['post_status'] ) && $data['post_status'] != 'auto-draft' ) {
    		$data['post_author'] = 1;
    	}
    
    	return $data;
    }
    add_filter( 'wp_insert_post_data', 'gd_snippet_190918_wp_insert_post_data', 100, 2 );

    Regards,
    Kiran

    #509391

    evocativemedia
    Expired Member
    Post count: 28

    Perfect, works like a charm! Thank you very much!

Viewing 9 posts - 1 through 9 (of 9 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount