Skip to content

Instantly share code, notes, and snippets.

View BhargavBhandari90's full-sized avatar
🏠
Working from home

Bhargav(Bunty) BhargavBhandari90

🏠
Working from home
View GitHub Profile
@BhargavBhandari90
BhargavBhandari90 / custom_post_type.php
Created July 26, 2020 18:00
Create custom post type in wordpress
<?php
/**
* Register a custom post type called "book".
*
* @see get_post_type_labels() for label keys.
*/
function wpdocs_codex_book_init() {
$labels = array(
'name' => _x( 'Books', 'Post type general name', 'textdomain' ),
@BhargavBhandari90
BhargavBhandari90 / php_open_ssl_encription_description.php
Created July 22, 2020 07:48
PHP OPENSSL ENCRIPTION DESCRIPTION
<?php
// Store a string into the variable which
// need to be Encrypted
$simple_string = "Welcome to GeeksforGeeks\n";
// Display the original string
echo "Original String: " . $simple_string;
// Store the cipher method
@BhargavBhandari90
BhargavBhandari90 / sidebars.php
Created July 20, 2020 16:41
Create custom widget area
<?php
/**
* Create custom sidebars.
* Add this into your theme's php file where you want put all the custom
* widget area code.
*/
function my_register_sidebars() {
/* Register the 'primary' sidebar. */
register_sidebar(
@BhargavBhandari90
BhargavBhandari90 / get_total_weekday_in_year.php
Last active November 20, 2023 05:49
Get total number of weekdays in a particular year.
<?php
/**
* Get total number of weekdays in a year.
*
* @param string $day Week day. Sun, Mon, Tue,...
* @param string $year Year in 4 digits.
* @return integer Return total number of specified weekday for a year.
*/
function get_total_weekday_in_year( $day = '', $year = '' ) {
@BhargavBhandari90
BhargavBhandari90 / multiple-user-tabs.php
Created July 9, 2020 18:32
Add multiple custom tabs on user profile for buddyboss and buddypress
<?php
/**
* Add custom sub-tab on user profile.
*/
function buddyboss_custom_user_tab() {
// Avoid fatal errors when plugin is not available.
if ( ! function_exists( 'bp_core_new_nav_item' ) ||
! function_exists( 'bp_loggedin_user_domain' ) ||
empty( get_current_user_id() ) ) {
@BhargavBhandari90
BhargavBhandari90 / add-tab-user-profile.php
Last active September 23, 2022 18:49
Add tab to user profile
<?php
/**
* Add custom sub-tab on groups page.
*/
function buddyboss_custom_user_tab() {
// Avoid fatal errors when plugin is not available.
if ( ! function_exists( 'bp_core_new_nav_item' ) ||
! function_exists( 'bp_loggedin_user_domain' ) ||
empty( get_current_user_id() ) ) {
@BhargavBhandari90
BhargavBhandari90 / change-default-tab.php
Last active June 27, 2020 17:22
Change default tab for group and user profile for buddyboss & buddypress
<?php
/**
* Change default tab for group.
*
* @param string $default_tab Slug of default tab.
* @return string
*/
function buddyboss_groups_default_extension( $default_tab ) {
return 'slug_of_tab'; // Last part of the URL.
}
@BhargavBhandari90
BhargavBhandari90 / buddypress-email-setting-manipulation.php
Last active June 23, 2020 18:38
Turn email notification OFF for new users for BuddyBoss and BuddyPress
<?php
/**
* Disable email notification.
*
* @param integer $user_id User ID.
* @return void
*/
function buddyboss_set_email_notifications_preference( $user_id ) {
@BhargavBhandari90
BhargavBhandari90 / buddypress-email-setting-manipulation.php
Created June 23, 2020 15:59
Manipulate email notification setting for user when they register for buddypress/buddyboss
<?php
function bpdev_set_email_notifications_preference( $user_id ) {
//I am putting some notifications to no by default and the common ones to yes to enable it.
//ref. https://bp-tricks.com/snippets/changing-default-buddypress-notifications-settings and BP forum
$settings_keys = array(
'notification_activity_new_mention' => 'yes',
'notification_activity_new_reply' => 'yes',
'notification_friends_friendship_request' => 'no',
'notification_friends_friendship_accepted' => 'no',
@BhargavBhandari90
BhargavBhandari90 / remove-tab.php
Created June 9, 2020 10:40
Remove tabs from user profile for BuddyBoss
<?php
/**
* Remove tabs from user profile.
*/
function remove_profile_nav() {
// Prevent fatal error if plugin is not available.
if ( ! function_exists( 'bp_core_remove_nav_item' ) ) {
return;
}