Created
May 19, 2022 19:35
-
-
Save woodwardtw/9f72d75a67107c840c56fd37e360abad to your computer and use it in GitHub Desktop.
for a gravity form with the ID of 1, adds a URL to feedwordpress assuming the fields are in the order presented
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'gform_after_submission_1', 'fwp_gf_url_adder', 10, 2 ); | |
function fwp_gf_url_adder($entry, $form){ | |
$url = rgar( $entry, '1' ); | |
$name = rgar( $entry, '2'); | |
$cat = rgar($entry, '3'); | |
$linkdata = array("link_url" => $url, | |
// varchar, the URL the link points to | |
"link_name" => $name, | |
// varchar, a URL of an associated RSS feed | |
"link_rss" => $url, | |
// int, the term ID of the link category. if empty, uses default link category | |
//remember these cat ids are for the link categories NOT post cats, set the id as a value in gf | |
"link_category" => (int)$cat | |
); | |
if (!function_exists('wp_insert_link')) { | |
include_once (ABSPATH . '/wp-admin/includes/bookmark.php'); | |
} | |
wp_insert_link($linkdata, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment