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.

6 Comments

mjasia · December 9, 2021 at 9:05 am

Hi!
Great!
how can I use this in um custom tab ?

Gabriel · February 9, 2022 at 10:32 am

Hey Ryner
Great tip. I have a question, I am currently building a site with Ultimate M. and I need registered users to vote for a particular UM profile. Do you know a way of doing this. Because in UM the User page is a generic that will pull each user but it is not specific. Thanks for any tip

corey · March 6, 2022 at 10:15 pm

Hello, I am trying to use this code and I am getting a blank page. I am trying to use code snippet plug in and also the post.php but when I enter it, it makes my user/post page blank. I am a noob and don’t really know what I am doing. I changed to the following.

// create your function

function custom_um_profile_query_make_posts( $args = array() )
{
$args[‘post_type’] = ‘animals’;

return $args;
}

// call your function using the UM hook

add_filter( ‘um_profile_query_make_posts’, ‘custom_um_profile_query_make_posts’, 12, 1 );

?>

betrand russel · March 3, 2023 at 8:53 am

hi, why you smart people, never specify where to put the code?
in theme functions or inultimate-member/includes/class-functions.php .. or where?
Thank you 🙂

denyt · February 9, 2024 at 4:52 am

dear ryner, which file should we change for adding the function, is it function.php on our theme?

    Ryner Galaus

    Ryner Galaus · March 12, 2024 at 3:19 am

    Hello, thank you. Indeed, all your functions should be included in the functions.php file of your child theme. Keep in mind that if you’re making edits to the main theme, not created by you, any updates from their developer/s will overwrite the changes you’ve made. I hope this information proves helpful! Thank you!

Leave a Reply

Avatar placeholder

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