Tagged: galleries, mediapress, woocommerce
I am using the following scripts to create 2 galleries per new user following registration. This works perfectly from the default free registration forms through Gravity Forms and the default WP form. However these galleries are not created if I do the registration through Woocommerce for some reason. Is this because of that bug I am avoiding on the WC checkout page and my stop_scripts fix is killing this from running? If so, is there a workaround? Please advise.
add_filter(‘mpp_load_js’, ‘smashing_wpp_stop_scripts’);
function smashing_wpp_stop_scripts( $content ){
if ( !is_user_logged_in() && is_checkout() ) {
return false;
}
return $content;
}/**
* Create 2 galleries for each type (video, photo, docs)
*/
function smashing_mpp_custom_create_gallery($user_id){if ( ! function_exists( ‘mpp_is_user_gallery_component’ ) ) {
return;
}$doc_gallery_id = mpp_create_gallery( array(
‘creator_id’ => $user_id,
‘title’ => sprintf( _x( “Athletic Docs”, ‘athletic documents’, ‘mediapress’ ), bp_core_get_user_displayname( $user_id ) ),
‘description’ => ”,
‘status’ => mpp_get_option( ‘default_status’ ),
‘component’ => ‘members’,
‘component_id’ => $user_id,
‘type’ => ‘doc’
) );
$doc_gallery_id2 = mpp_create_gallery( array(
‘creator_id’ => $user_id,
‘title’ => sprintf( _x( “Academic Docs”, ‘academic documents’, ‘mediapress’ ), bp_core_get_user_displayname( $user_id ) ),
‘description’ => ”,
‘status’ => mpp_get_option( ‘default_status’ ),
‘component’ => ‘members’,
‘component_id’ => $user_id,
‘type’ => ‘doc’
) );if ( $doc_gallery_id ) {
mpp_update_wall_gallery_id( array(
‘component’ => ‘members’,
‘component_id’ => $user_id,
‘media_type’ => ‘doc’,
‘gallery_id’ => $doc_gallery_id
) );
}
if ( $doc_gallery_id2 ) {
mpp_update_wall_gallery_id( array(
‘component’ => ‘members’,
‘component_id’ => $user_id,
‘media_type’ => ‘doc’,
‘gallery_id’ => $doc_gallery_id2
) );
}}
add_action( ‘bp_core_activated_user’, ‘smashing_mpp_custom_create_gallery’ );Hi Leland,
WooCommerce does not fire the ‘bp_core_activated_user’. That’s why it is not working.I will suggest changing
add_action( 'bp_core_activated_user', 'smashing_mpp_custom_create_gallery' );
to
add_action( 'user_register', 'smashing_mpp_custom_create_gallery' );
That will make it work for all cases.
Regards
BrajeshGreat! I figured it was something to do with that action function. Thank you!
You must be logged in to reply to this topic.