Last active
April 6, 2022 11:52
-
-
Save yuriinalivaiko/be0328e3b4625ce8cf2f31d1ca7d0dd0 to your computer and use it in GitHub Desktop.
This code snippet adds a link "Edit private content" to the profile under the private content.
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 | |
/** | |
* Add a button to the member profile that an admin can click so they are redirected to the private content of the relevant member | |
* @author Ultimate Member support <support@ultimatemember.com> | |
* @since 2022-03-17 | |
* @see #59138 | |
*/ | |
add_action( 'um_profile_content_private_content', function( $args ) { | |
if ( is_user_logged_in() && current_user_can( 'administrator' ) && current_user_can( 'edit_user', um_profile_id() ) ) { | |
$private_content_link = UM()->Private_Content()->get_private_content_post_link( um_profile_id() ); | |
echo '<div class="um-col-alt"><a href="' . esc_url( $private_content_link ) . '" class="um-button">' . __( 'Edit private content', 'um-private-content' ) . '</a></div>'; | |
} | |
}, 20 ); | |
add_filter( 'um_user_profile_tabs', function( $tabs ) { | |
if ( empty( $tabs['private_content'] ) && is_user_logged_in() && current_user_can( 'administrator' ) && current_user_can( 'edit_user', um_profile_id() ) ) { | |
$tab_title = UM()->options()->get( 'tab_private_content_title' ); | |
$tab_icon = UM()->options()->get( 'tab_private_content_icon' ); | |
$tabs['private_content'] = array( | |
'name' => ! empty( $tab_title ) ? $tab_title : __( 'Private Content', 'um-private-content' ), | |
'icon' => ! empty( $tab_icon ) ? $tab_icon : 'um-faicon-eye-slash', | |
'default_privacy' => 2, | |
); | |
} | |
return $tabs; | |
}, 1001, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected result: