Last active
March 25, 2019 18:34
-
-
Save scottopolis/4f2b7aaa186be07092abd906c2763af3 to your computer and use it in GitHub Desktop.
AppCommunity Template Hook Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// this code goes in a plugin | |
// Add a member profile field to the app | |
add_filter( 'appcommunity_prepare_user', function( $response, $request ) { | |
$response['appp']['user_actions'] = '<div padding><p class="custom-profile-field"><strong>' . xprofile_get_field( 1, $request['id'] )->name . '</strong><br/>' . xprofile_get_field_data( 1, $request['id'] ) . '</p><p class="custom-profile-field"><strong>' . xprofile_get_field( 2, $request['id'] )->name . '</strong><br/>' . xprofile_get_field_data( 2, $request['id'] ) . '</p></div>'; | |
return $response; | |
}, 10, 2 ); | |
// Add a field to the group detail page | |
add_filter( 'appcommunity_prepare_group', function( $response, $request ) { | |
$response['appp']['above_content'] = '<p>Member count: ' . groups_get_groupmeta( $response['id'], 'total_member_count', 1 ) . '</p>'; | |
$response['appp']['below_content'] = 'Thanks for visiting my group!'; | |
return $response; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment