Viewing 6 replies - 1 through 6 (of 6 total)
  • You are probably missing the part where you specify to your shortcode who is the current user, as an example:

    global $current_user;
    get_currentuserinfo();
    $user_id = $current_user->ID;
    $email = $current_user->user_email;
    Thread Starter jturet

    (@jturet)

    This is my custom shortcode:

    function mailpoet_shortcodes_custom_filter( $tag_value , $user_id) {
    
    		if ($tag_value === 'my_division') {
    			$replacement = get_user_field ("full_name", $user_id);
    		}
    
    		if ($tag_value === 'my_director_email') {
    			$replacement = get_user_field ("user_email", $user_id);
    		}
    
    		if ($tag_value === 'director1_fullname') {
    			$replacement = get_user_field ("listserv_d1fn", $user_id);
    		}
    
    		if ($tag_value === 'director1_phone') {
    			$replacement = get_user_field ("listserv_d1pn", $user_id);
    		}
    
    		if ($tag_value === 'director2_fullname') {
    			$replacement = get_user_field ("listserv_d2fn", $user_id);
    		}
    
    		if ($tag_value === 'director2_phone') {
    			$replacement = get_user_field ("listserv_d2pn", $user_id);
    		}
    
    		if ($tag_value === 'director3_fullname') {
    			$replacement = get_user_field ("listserv_d3fn", $user_id);
    		}
    
    		if ($tag_value === 'director3_phone') {
    			$replacement = get_user_field ("listserv_d3pn", $user_id);
    		}
    
    		if ($tag_value === 'blog_name') {
    			$replacement = get_bloginfo('name');
    		}
    
    		return $replacement;
    	}
    
    	add_filter('wysija_shortcodes', 'mailpoet_shortcodes_custom_filter',10 ,2);

    Everything works perfectly besides setting the $user_id to be that of the sender. I cannot figure out a way to do this. Using your suggestion it still gets the currently logged in user’s ID not that of the sender. Is there any sort of built in newsletter ‘ownership’ associated to the user who sends the message? I am at a complete loss.

    Thread Starter jturet

    (@jturet)

    What exactly is the interp_shortcode hidden option and would it solve my problem?

    https://gist.github.com/CFXd/7e15b756f2b2c64c23d8

    Thread Starter jturet

    (@jturet)

    Still looking for an answer

    No it won’t. That function/parameter is to enable shortcodes contained in WordPress Posts. We strongly advise everyone to not use that as our render will probably crash.

    You’ve said:
    Everything works perfectly besides setting the $user_id to be that of the sender. I cannot figure out a way to do this. Using your suggestion it still gets the currently logged in user’s ID not that of the sender. Is there any sort of built in newsletter ‘ownership’ associated to the user who sends the message? I am at a complete loss.

    Okay, but the “sender” is not the current logged in user?

    Thread Starter jturet

    (@jturet)

    The sender is the currently logged in user, however the shortcode remains dynamic and changes depending on who views the message. I need the shortcode to be executed and stay static.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom Shortcode: Sender Meta’ is closed to new replies.