• Resolved Lars Henriksen

    (@adjunkten)


    Hi Paul,

    I have a list of users who create events with Events manager.
    It would be nice if their latest event could be shown in the author list.

    So would it be an idea to include more post types in the query for ‘show link to authors last post’ ? Like for instance ‘events’ , ‘topics’ (bbpress) ?

    Thanks,
    Lars

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Paul Bearne

    (@pbearne)

    Hi Lars,

    That sounds like a good idea
    I will have to look at how to do it etc.

    Paul

    Plugin Author Paul Bearne

    (@pbearne)

    Hi Lars

    I have already coded a filter ‘aa_user_show_last_post_type’ you can use this to change the post type

    Paul

    	$args     = array(
    			'author'              => $user_id,
    			/**
    			 * Filter the users last post type. Default is "posts"
    			 *
    			 * @since 1.9.2
    			 *
    			 * @param int $user_id The Current user ID.
    			 */
    			'post_type'           => apply_filters( 'aa_user_show_last_post_type', 'post', $user_id ),
    			'post_status'         => 'publish',
    			'posts_per_page'      => 1,
    			'ignore_sticky_posts' => 1,
    		);
    Thread Starter Lars Henriksen

    (@adjunkten)

    Hi Paul

    Thank you for working on this .

    I am not so comfortable with editing source code…I can only add snippets to functions.php.

    Or is there any other way I can try your filter?

    Cheers Lars

    Plugin Author Paul Bearne

    (@pbearne)

    try this sniped adjust the post type name as needed

    `add_filter(‘aa_user_show_last_post_type’, function(){

    return ‘events’; // the event post type name get from url in wp-admin
    });

    Thread Starter Lars Henriksen

    (@adjunkten)

    Thanks, but I get a critical error when I use this in Code snippets.

    This is the log:

    Uncaught Error: Undefined constant "‘aa_user_show_last_post_type’" in /nas/content/live/dhta/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(253) : eval()'d code:1 Stack trace: #0 /nas/content/live/dhta/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(253): eval() #1 /nas/content/live/dhta/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(312): Code_Snippets\Edit_Menu->test_code(Object(Code_Snippets\Snippet)) #2 /nas/content/live/dhta/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(150): Code_Snippets\Edit_Menu->save_posted_snippet() #3 /nas/content/live/dhta/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(82): Code_Snippets\Edit_Menu->process_actions() #4 /nas/content/live/dhta/wp-includes/class-wp-hook.php(307): Code_Snippets\Edit_Menu->load('') #5 /nas/content/live/dhta/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array) #6 /nas/content/live/dhta/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #7 /nas/content/live/dhta/wp-admin/admin.php(237): do_action('load-snippets_p...') #8 {main} thrown

    Plugin Author Paul Bearne

    (@pbearne)

    It looks like the text had fancy quotes

    add_filter(“aa_user_show_last_post_type”, function(){

    return “events”; // the event post type name get from url in wp-admin
    });

    Thread Starter Lars Henriksen

    (@adjunkten)

    OK-confirmed , this works… if you pay attention to the fancy quotes – powerful small bugs ?? Thank you for your patience with me.

    Would it be too hard to show the authors newest event OR post: If post is the most recent, show post, if event, show event.

    Cheers, Lars

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Include other post types in ‘show authors last post’?’ is closed to new replies.