Skip to content

Instantly share code, notes, and snippets.

@scottopolis
Last active March 25, 2019 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottopolis/4f2b7aaa186be07092abd906c2763af3 to your computer and use it in GitHub Desktop.
Save scottopolis/4f2b7aaa186be07092abd906c2763af3 to your computer and use it in GitHub Desktop.
AppCommunity Template Hook Example
<?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