By default, in the Ultimate Member profile page at the posts tab, it only shows the “post” post_type of a user.

This is the page I am talking about:
https://rynerworld.com/user/ryner/?profiletab=posts.

It doesn’t really show the posts of custom post types. So here is a quick fix for that.

Simple Code

<?php

// create your function

function custom_um_profile_query_make_posts( $args = array() ) 
{
	$args['post_type'] = 'custom_post_type';

	return $args;
}

// call your function using the UM hook

add_filter( 'um_profile_query_make_posts', 'custom_um_profile_query_make_posts', 12, 1 );

?>


This is the ultimate churvaness to change the posts displayed at the profile page.

Reminder tho, with this code, we have overridden the post type that is shown, meaning, the posts with the “post” post_type will not be shown.

So to fix this, we pass an array.

<?php

// create your function

function custom_um_profile_query_make_posts( $args = array() ) 
{
	$args['post_type'] = ['post','custom_post_type'];

	return $args;
}

// call your function using the UM hook

add_filter( 'um_profile_query_make_posts', 'custom_um_profile_query_make_posts', 12, 1 );

?>


There you go! Now we are showing both post types. This can also be used for more post types.

Code inside a class

If you are working inside a class, you simply need to add one word lol.

<?php
if( ! class_exists('RYNERWORLD') ) :
class RYNERWORLD
{

	function __construct() {
		add_filter( 'um_profile_query_make_posts', [$this, 'custom_um_profile_query_make_posts'], 12, 1 );
	}

	function custom_um_profile_query_make_posts( $args = array() ) {

		$args['post_type'] = ['post','custom_post_type'];

		return $args;

	}
}
new RYNERWORLD();
endif;
?>


Proof?

For proof that it actually works, visit this one:
https://rynerworld.com/user/diannemae/?profiletab=posts
The posts for this user have “entry” post_type. That’s the proof lol.

Additionals

For more information, you can visit the Ultimate Member Documentation regarding this. Though it really does lack information. hahaha
Cheers!

If you have any questions, comment below.
And if you think this is kinda helpful, share it with your friends? hihihi

Happy coding!


Ryner Galaus

Ryner SG

An ordinary person with a tiny brain hoping to be useful in his own way. A homebody hoping to one day create and build his dreams while in service to people. An underachiever who was once called nobody slowly growing up. A web developer learning and earning his way through life. Ryner is what my family and friends call me, and I hope you do too. By the way, I am also affiliated with Frontrow International, so for inquiries or orders, message me.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *