Add one more argument

Hey guys,

Trying to add a 3rd arguement to my function. IF john-doe and penny-doe are together THEN group them as “John Doe \ Manager, Penny Doe \Assistance manager”

Need some assistance pls

function export_agent_lookup( $agent ) {
	$replacements = array(
		"john-doe" => "John Doe \ Manager",
		"penny-doe" => "Penny Doe \ Assistance manager"
	);
    return str_replace( array_keys($replacements), $replacements, $agent);
}

How do you decide whether they are “together”?

Hi Droop,

Good question, the plugin I’m using knows items are together by adding a “>”

I’m calling the function using “[export_agent_lookup({listingAgent[1]})]” which grabs the listing agent ID from the XML file. Basically trying to match the listingAgent[ID] and marry the two together with a “>”

But by “together”, do you mean adjacent in the array inside the function, or is there some other way to determine that one agent is with another one, based on the ID you put in? So if you send “john-doe” as the ID, what will tell your data that it should also link to another array element?

The only thing I could think of would be to have a “group” code of some sort as an additional element in your array, find the entry you want using the ID, then check the “associated with” code and append any other elements that also include it.

pretty sure the agents are already stored in an array with a primary ID.

I’m just trying to grab ID 1 and 2 which will display them as one in a foreach loop

So asked the developer about how agents are binded

This theme uses MetaBox plugin to add those MetaBoxes. You can see a block of code that generates a list of agent posts titles to use in Metabox Options around line #52 in the “config-meta-boxes.php” file located under framework/meta-box/ directory.

Look at this screenshot: http://jmp.sh/iAe8gpc

Now you can find the MetaBox field code around line #320 in the same file.

Helping screenshot: http://jmp.sh/9OHQWEb

For any further assistance, please reach our support site and our support team will take care of you.

Regards,

agent_posts->ID could be the variable I need

Al though I know I just need to get ID [1] and [2]

What are your thoughts on this

`function export_agent_lookup( $agent ) {
$replacements = array(
	"1" => "John Doe – Director\Licensee\Sales Agent",
	"2" => "Penny Doe – Sales Agent",
	"1" . "2" => "John Doe – Director\Licensee\Sales Agent" . ">" . "Penny Doe – Sales Agent"
);
return str_replace( array_keys($replacements), $replacements, $agent);
}`
$replacements = array(
	"1" => "John Doe – Director\Licensee\Sales Agent",
	"2" => "Penny Doe – Sales Agent",
	"1" . "2" => "John Doe – Director\Licensee\Sales Agent" . ">" . "Penny Doe – Sales Agent"
);

My concern with the above would be - how does your array know that the index “1” . “2” is different from the index “12”?

I’m assuming the array you are showing in your function is just the start of a much larger array that contains all the agents - is that correct, or will it only ever have these two in it? I can’t see it would be worth writing a function if it’s only going to have these two hard-coded entries in it.

But what I’m trying to get at is - how does your code figure out which agents are related? Is that a hard-coded relationship, or is there something in the database that links the two? You say “although I know I just need to get ID[1] and [2]” above, is that only ever going to be the case, or might there be a link between, say, agents 34, 35 and 36? And if so, where does the information for that link come from?

(I know nothing about MetaBox, in case I haven’t made that clear by my responses. I am learning PHP. So if this is specific to whatever MetaBox is, I probably can’t help.)

Yeah not sure.

This page probably explains it better http://www.wpallimport.com/documentation/advanced/execute-php/

Doesn’t explain how your code is going to know if or when there is a link between one or more agents, nor whether your array will contain more than the two agents listed, and whether it’s hard-coded or retrieved from a database somewhere. I think I must have missed out on exactly what you’re trying to do here, and I still don’t understand how you define “together” in a way that can be handled in code.

Let’s leave it for now, thanks for trying

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.