Skip to content

Instantly share code, notes, and snippets.

@ultimatemember
Last active April 19, 2021 20:35
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ultimatemember/8cdaf61e7bd9de35512c to your computer and use it in GitHub Desktop.
Save ultimatemember/8cdaf61e7bd9de35512c to your computer and use it in GitHub Desktop.
Extending Ultimate Member Profile Menu using Hooks
/* First we need to extend main profile tabs */
add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 );
function add_custom_profile_tab( $tabs ) {
$tabs['mycustomtab'] = array(
'name' => 'My custom tab',
'icon' => 'um-faicon-comments',
);
return $tabs;
}
/* Then we just have to add content to that tab using this action */
add_action('um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default');
function um_profile_content_mycustomtab_default( $args ) {
echo 'Hello world!';
}
@moserello
Copy link

moserello commented Feb 16, 2021

I just tried to add a shortcode in a custom tab with the following:

`add_filter('um_account_page_default_tabs_hook', 'add_kd_redeem_tab', 100 );
function add_kd_redeem_tab( $tabs ) {
$tabs[800]['redeem_kd_tab']['icon'] = 'um-icon-ios-world';
$tabs[800]['redeem_kd_tab']['title'] = 'Title';
$tabs[800]['redeem_kd_tab']['custom'] = true;
return $tabs;
}

add_action('um_account_tab__redeem_kd_tab', 'um_account_tab__redeem_kd_tab');
function um_account_tab__redeem_kd_tab( $info ) {
global $ultimatemember;
extract( $info );

$output = $ultimatemember->account->get_tab_output('redeem_kd_tab');
if ( $output ) { echo $output; }

}

add_filter('um_account_content_hook_redeem_kd_tab', 'um_account_content_hook_redeem_kd_tab');
function um_account_content_hook_redeem_kd_tab( $output ){
ob_start();
?>

<div class="um-field">
	
    <?php echo do_shortcode("[mycred_load_coupon label='Insert code here' button='Redeem']"); ?>
    		
</div>		
	
<?php
	
$output .= ob_get_contents();
ob_end_clean();
return $output;

}`

  1. The shortcode displays correctly but when I hit the button I just get a page refresh instead of triggering the button generated by the shortcode
  2. The shortcode works properly if put in the account page, outside tabs

The shortcode that I'm using is here:
https://codex.mycred.me/shortcodes/mycred_load_coupon/

What am I missing?
Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment