Skip to content

Instantly share code, notes, and snippets.

Avatar

Giang Le gianghl1983

  • Thiết kế Website Chuyên nghiệp Thanh Hóa
  • Việt Nam
View GitHub Profile
View Example of Ultimate Member Cover photo in Open Graph Image meta
add_action("init","um_custom_init");
function um_custom_init(){
remove_action('wp_head', 'um_profile_dynamic_meta_desc', 9999999);
}
add_action('wp_head', 'um_custom_profile_dynamic_meta_desc', 9999999);
function um_custom_profile_dynamic_meta_desc() {
global $ultimatemember;
if ( um_is_core_page('user') && um_get_requested_user() ) {
um_fetch_user( um_get_requested_user() );
View Ultimate Member - Hides current user from search query in member directory
<?php
/**
* Hides current user from search query in member directory
*/
add_filter('um_prepare_user_query_args', 'um_remove_current_user_from_query', 10, 2);
function um_remove_current_user_from_query( $query_args, $args ){
$query_args['exclude'] = array( get_current_user_id() );
return $query_args;
View Ultimate Member - change display name with custom name per user role
<?php
// Requires Ultimate Member v1.3.68+
// Change Displayname for Business category profiles
add_filter("um_user_display_name_filter","um_custom_businessname", 10, 2);
function um_custom_businessname( $name, $profile_id ){
um_fetch_user( $profile_id );
if( um_user('role') == 'business' ){
$name = um_user("first_name");
}
View Ultimate Member - Add menu items in Profile Settings menu
<?php
add_filter("um_profile_edit_menu_items","um_custom_profile_edit_menu_items",10,2);
function um_custom_profile_edit_menu_items( $items, $profile_id ){
$items[ ] = array(
"my_custom_menu_item" => '<a href="http://example.com/" class="real_url">'.__('My Custom Menu Item','ultimatemember').'</a>',
);
return $items;
@gianghl1983
gianghl1983 / usermeta-shortcode.php
Created Mar 19, 2019 — forked from dave-mills/usermeta-shortcode.php
A WordPress custom shortcode to display a piece of user metadata from the wp_usermeta table. Relies on Ultimate Member plugin
View usermeta-shortcode.php
/* Create new shortcode for quickly displaying user metadata.
*** NOTE: This only works if you have the Ultimate Member plugin installed.
*** Use like regular wordpress shortcodes. Enter [USERMETA user_id="*id*" meta="*field_name*"] (replace *id* and *field_name* with actual values)
*** If you use it on an Ultimate Member profile page/tab, it will use the user currently being viewed.
*** On other pages, you must include the "user_id" within the shortcode.
*/
//Add the shortcode to WordPress
add_shortcode('USER_META', 'user_meta_shortcode_handler');
//create the function referenced by the add_shortcode()
View Ultimate Member - Hide profile tabs from other user roles
<?php
add_filter('um_profile_tabs', 'pages_tab', 1000 );
function pages_tab( $tabs ) {
$user_id = um_get_requested_user();
// Show to profile owners only
if ( is_user_logged_in() && get_current_user_id() == $user_id ) {
$tabs['faves'] = array(
'name' => 'Faves',
'icon' => 'fa fa-star',
View Ultimate Member Groups - Create discussion post
function wpuf_post_umgroup( $post_id, $form_id ) {
/* Build the post content by adding the referer URL to the comment and update the post */
$lv_comment = $_POST['_my_comment'] . PHP_EOL . PHP_EOL . home_url() . wp_get_referer();
$lv_post = array();
$lv_post['ID'] = $post_id;
$lv_post['post_author'] = get_current_user_id();
$lv_post['post_content'] = $lv_comment;
View connect
<?php
$server = 'localhost';
$username = 'giang2424_demo';
$password = '05012011';
$database = "giang2424_quanlythuchi";
$db_qltc = new mysqli($server, $username, $password, $database);//Thay tên $db_qltc
$db_qltc->set_charset('utf8');
if ($db_qltc->connect_error) {
echo "<br>Lỗi kết nối";
View account_edit
<?php
include ('database/connect.php');
//B1 = check ID
//B2= nap lai data
//B3= update
$errors = [];
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
View account_del
<?php
include ('database/connect.php');
// <a href="account.del.php?id=<?php echo $account['id'];
/**
* Xóa dữ liệu: Có 2 cách (Logic, Vật ly)
* + Logic (Cập nhật 1 trạng thái nào đó mà mình quy định nó sẽ được hiểu là bản ghi được xóa). delete_flag (1: Xóa, o: Tồn tại)
* => Dữ liệu không mất, khi cần có thể backup lại. Tuy nhiên, khi xử lý, phức tạp hơn xóa vật lý vì các dữ liệu sẽ liên đới với nhau.
* + Vật lý: Xóa mất luôn data trong CSDL. Dễ thao tác, dễ triển khai, nhưng rủi ro mất dữ liệu cao.
* Luân chuyển dữ liệu:
* Thay vì xóa đi, thì mình chuyển dữ về sang 1 table nháp, hoặc database nào đó, hoặc cập nhật sang 01 danh mục.