Skip to content

Instantly share code, notes, and snippets.

@itthinx
Last active May 25, 2018
Embed
What would you like to do?
Affiliate Registration issue
<?php
// from https://www.itthinx.com/topic/affiliate-registration-issue-2/
// the snippet for the form action which currently works looks like this:
function referring_affiliate_form_action ( $atts ) {
$output_form_action = '';
if ( !is_admin() ) {
if ( !class_exists( "Affiliates_Service" ) ) {
include_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' );
}
$affiliate_id_form_action = Affiliates_Service::get_referrer_id();
if ( $affiliate_id_form_action && $affiliate_id_form_action != affiliates_get_direct_id() ) {
if ( $user_id_form_action = affiliates_get_affiliate_user( $affiliate_id_form_action ) ) {
if ( $user_form_action = get_user_by( 'id', $user_id_form_action ) ) {
$output_form_action .= '' ;
if (
get_user_meta( $user_id_form_action, 'form_action' , true ) &&
( get_user_meta( $user_id_form_action, 'form_action' , true )!== "" )
) {
$output_form_action .=''.get_user_meta( $user_id_form_action, 'form_action' , true ).'';
}
}
}
}
}
return $output_form_action;
}
// The input value shortcode that just renders as a shortcode and doesn't work looks basically the same.
add_action( 'init', 'referring_affiliate_input_value_shortcode' );
function referring_affiliate_input_value_shortcode() {
add_shortcode( 'referring-affiliate-input_value', 'referring_affiliate_input_value' );
}
function referring_affiliate_input_value ( $atts ) {
$output_input_value = '';
if ( !is_admin() ) {
if ( !class_exists( "Affiliates_Service" ) ) {
include_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' );
}
$affiliate_id_input_value = Affiliates_Service::get_referrer_id();
if ( $affiliate_id_input_value && $affiliate_id_input_value != affiliates_get_direct_id() ) {
if ( $user_id_input_value = affiliates_get_affiliate_user( $affiliate_id_input_value ) ) {
if ( $user_input_value = get_user_by( 'id', $user_id_input_value ) ) {
$output_input_value .= '' ;
if (
get_user_meta( $user_id_input_value, 'input_value' , true ) &&
( get_user_meta( $user_id_input_value, 'input_value' , true )!== "" )
) {
$output_input_value .=''.get_user_meta( $user_id_input_value, 'input_value' , true ).'';
}
}
}
}
}
return $output_input_value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment