BuddyPress User Field: Number of log entries to show

Home / Tutorials / BuddyPress User Field: Number of log entries to show

Description

In this short tutorial I will show you how you can setup a custom user field where your members can set how many rows myCRED should show when they are viewing their points history. If the user does not change this value, the default number of rows will be returned.

Requirements

  • myCRED 1.3 +
  • BuddyPress Add-on enabled
  • BuddyPress User Field Component enabled

The User Field

First, we need to create a custom user field which will hold the number of rows a user want to show. As with all user fields, we create them under the “Users” menu item in our admin area.

It does not matter under which group you save this field or what you call it. Just make sure you select “Text Field” as field type and make a note of the title you set.

Hooking into myCRED

The number of rows shown for each users points history is set by the¬†mycred_bp_history_num_to_show filter. We can use this filter to grab our users set value and if it’s not empty, use that value.

add_filter( 'mycred_bp_history_num_to_show', 'buddypress_number_of_rows_to_show' );
function buddypress_number_of_rows_to_show( $num ) {
	$user_id = bp_displayed_user_id();
	$number = xprofile_get_field_data( 'Your User Fields Title', $user_id );
	if ( ! empty( $number ) )
		return $number;

	return $num;
}

Make sure you replace the above field name with your own title and make sure it matches exactly.

Done!

Add the above code to your themes functions.php file and upload. Once done, visit your BuddyPress profile and edit your settings. Set the number of rows you want to see and save. If you visit the myCRED Log page in your BuddyPress profile, you should now see the set number of rows (if there are that many).

  1. I just need a Huge help!!!… I have loads of questions and I hope Gabriel will help!!….
    1. How and where can I add shortcodes for users buying points(the buy form), click link(will I create a special page which I’ll add the code for links to be clicked on), and Video.

    2. Talking about Post and Page selling, I need more details (because I’m using buddypress and Bbpress for my website but I don’t know how my users will sell a post) is it by updating stuffs on buddypress?…(I seriously need help)

    3. I’m from Nigeria, please none of the Gateways accept my country, can you add any other gateway please?, or what can I do?

    4. Points made by users on my site, does it convert to real cash during payout? And how can I add the payout buttons to my site?

    5. Talking about me as site owner how do I make money from my site. (I want to be home working on my website to make money, is it possible with Mycred)

    6. Mycred works fine for my buddypress, atleast I registered on my site to see how it works, I received points for sign up. But other parts of the activities like Sell post/page, content author, publishing post is what I don’t know how to arrive on… Does mycred have an activity stream for this? Or it is what happends on the buddypress activity stream?…
    Note: Have set up all points already at the Hooks, I’ve activated the Add-on I need…..
    Just want to know deep about the questions above because I’m new when it comes to monetizing website…
    Less I forget Gabriel, Thanks for this wonderful plugin.. Love you.

    1. Hello.

      1. You add shortcodes either into your page’s content field or into your themes template file.

      2. Users sell access to post content. This means that your users need to have the capability to publish the post type you want them to sell. For example you can always sell “Posts” which is separate from bbPress and BuddyPress or any other post type your site uses. You will need to tell myCRED what post types you want to sell by adjusting your Sell Content settings on the myCRED > Settings page.

      3. You would need to create a custom payment gateway that is accepted in Nigeria. The four that is included with myCRED is the only ones currently supported.

      4. myCRED has no built in “payout” feature. It is up to you to either build one or manually deduct the points from your users when you pay them out yourself.

      5. This is nothing to do with myCRED. I can not give you advice on how to use your website to make money or how to use WordPress. Google is your best friend for these type of questions.

      6. myCRED does not have an activity stream. It has a log where all transactions are kept. This log is inserted into your users profiles. Make sure you have visited the myCRED > Settings page and adjusted your settings to your liking.

Leave a Reply

Last edited October 28, 2016