wonder if you can help me.

I'm trying to get an action (geodir_after_save_listing) to change a user role.

Basically, in Geo Directory, when the user submits a business listing, I want to change their role from "member" to "member_with_business"

I believe the geo_dir_after_save_listing is still a relevant action (awaiting response from GeoDirectory support) so IMO the php snippet below should work?

add_action('geodir_after_save_listing', 'change_user_role_when_submit_business');

function change_user_role_when_submit_business( $last_post_id, $request_info ) {
  $gd_post_type = geodir_get_current_posttype();

    if ($gd_post_type == 'gd_place') {

    $user = wp_get_current_user();
    $roles = $user->roles;
    if (in_array('member', $roles)){
        $user->add_role( 'member_with_business' );
        $user->remove_role( 'member' );

Any thoughts from those more php savvy than me?

New contributor
Mark Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Mark Lee is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.