Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Last active February 13, 2025 13:39
Show Gist options
  • Save yuriinalivaiko/dea3ebbaee3782ef71ff749e461aeefb to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/dea3ebbaee3782ef71ff749e461aeefb to your computer and use it in GitHub Desktop.
Code snippets for the "User Bookmarks" extension
<?php
// Disable the default "Bookmark" button in the post content.
if ( defined( 'um_user_bookmarks_version' ) ) {
remove_filter( 'the_content', array( UM()->User_Bookmarks()->common(), 'add_um_user_bookmarks_button' ), 20 );
remove_filter( 'the_excerpt', array( UM()->User_Bookmarks()->common(), 'add_um_user_bookmarks_button_excerpt' ), 9999 );
}
<?php
/**
* Adds a "Bookmark" button to the note "View" screen.
* Select the "Notes" option in the "Enable bookmark" setting to enable this button.
*/
if ( defined( 'um_user_bookmarks_version' ) && in_array( 'um_notes', (array) UM()->options()->get( 'um_user_bookmarks_post_types' ), true ) ) {
add_action( 'um_after_template_part', function( $template_name, $path, $located, $args ) {
if ( 'profile/view.php' === $template_name && 'um-user-notes' === $path ) {
UM()->User_Bookmarks()->common()->get_bookmarks_button( $args['id'] );
}
}, 10, 4 );
}
@yuriinalivaiko
Copy link
Author

A code in the um_user_notes_bookmarks_button.php gist adds the "Bookmark" button to the note modal view. This is a kind of integration between the User Bookmarks and User Notes extensions.

Once the code is added go to wp-admin > Ultimate Member > Settings > Extensions > User Bookmarks and select the Notes option in the Enable bookmark setting to enable this feature.
UM Settings, Extensions, User Bookmarks (Enable bookmark + Notes)_cr

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