Skip to content

Instantly share code, notes, and snippets.

@svenl77
svenl77 / buddyforms-vs-event-list-integration.php
Last active February 6, 2024 09:39
BuddyForms VS Event List Integration
<?php
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/*
* Plugin Name: BuddyForms VS Event List
* Description: BuddyForms VS Event List Integration
* Version: 0.1
* Author: ThemeKraft
<?php
function my_buddyforms_excerpt_length($length){
global $post, $buddyforms;
if( !isset($post->ID) ){
return $length;
}
@svenl77
svenl77 / buddyforms_update_form_title.php
Created October 21, 2022 08:33
buddyforms_update_form_title
<?php
add_filter( 'buddyforms_update_form_title', 'buddyforms_update_form_title_user_id',9999, 3 );
function buddyforms_update_form_title_user_id( $post_title, $form_slug, $post_id ) {
$post_title = str_replace('[post_id]', $post_id, $post_title);
// in here
$post = get_post($post_id);
$author_id = $post->post_author;
$post_title = str_replace('[author_id]', $author_id, $post_title);
@svenl77
svenl77 / ultimate-member-invite-codes.php
Created October 1, 2022 12:17
Add All In One invite Codes Validation to a Ultimate Member Registration Field
<?php
/**
* Validate field Mobile Number
* @param string $key
* @param attay $array
* @param array $args
*/
function um_custom_validate_invite_code( $key, $array, $args ) {
if(!function_exists('all_in_one_invite_codes_validate_code')){
@svenl77
svenl77 / buddyforms_add_id_to_title.php
Last active March 23, 2020 12:56
This is an example function on how to add any kind of value to the title. In this case we use the post id
<?php
add_filter( 'buddyforms_update_form_title', 'buddyforms_add_id_to_subject', 9999 , 3 );
function buddyforms_add_id_to_subject( $default_post_title, $form_slug, $post_id ){
if($form_slug != 'simple-post-form'){
return $default_post_title;
}
return $default_post_title . '-' . $post_id;
@svenl77
svenl77 / buddyforms_the_author_id.php
Last active March 2, 2020 13:17
BuddyForms filter buddyforms_the_author_id to overwrite the author of a post during submission
<?php
//
// Add the auto_assign_user id as post author if auto_assign_user is set for this form
//
add_filter( 'buddyforms_the_author_id', 'buddyforms_auto_assign_user',10 , 2 );
function buddyforms_auto_assign_user($author_id, $form_slug){
// Check if anonymous author is set
if( ! isset( $_POST['auto_assign_user'] ) ){
return $author_id;
<?php
function buddyforms_redirect_a_page_to_the_buddypress_profile() {
if( is_page( 2 ) ) {
if(is_user_logged_in()){
wp_safe_redirect( bp_loggedin_user_domain() );
exit;
}
}
}
<?php
/**
* Enqueue GMW scripts outside the shortcode during page load.
*
* @return [type] [description]
*/
function gmw_custom_load_sctips() {
GMW_Maps_API::load_scripts();
<?php
add_filter( 'gmw_pt_search_query_args', 'buddyforms_geowp_data', 10, 2 );
function buddyforms_geowp_data( $query_args, $form ) {
global $wp_querie;
// echo '<pre>';
// print_r($query_args);
// echo '</pre>';
@svenl77
svenl77 / buddyforms_user_posts_query_args.php
Last active December 6, 2018 13:21
You can use any query parameter from WP_Query: https://codex.wordpress.org/Class_Reference/WP_Query if you want to change the post per page you can also use this filter: buddyforms_user_posts_query_args_posts_per_page
<?php
/*
* Manipulate the user posts list query
*/
add_filter( 'buddyforms_user_posts_query_args', 'my_buddyforms_user_posts_query_args', 10, 1 );
function my_buddyforms_user_posts_query_args( $query_args ){
global $buddyforms;
$query_args['cat'] = '4';